Logo

Maarten Balliauw {blog}

ASP.NET, ASP.NET MVC, Azure, PHP, OpenXML, VSTS, ...

About the author

Maarten Balliauw is an MVP ASP.NET and is currently employed as .NET Software Engineer at RealDolmen. His interests are mainly web applications developed in ASP.NET (C#) or PHP.
More about me More about me
Send mail E-mail me


Microsoft Most Valuable Professional - MVP - ASP.NET

Subscribe to my RSS feed Follow me on Twitter! View Maarten Balliauw's profile on LinkedIn RealDolmen - Rock-solid passion for ICT
I'm a speaker at TechDays Belgium and TechDays Finland

Search

Latest Twitter

    Follow me on Twitter...

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

    © Copyright Maarten Balliauw 2010

    PHPPowerPoint 0.1.0 (CTP1) released!

    PHPPowerPoint logo People following me on Twitter could have already guessed, but here’s something I probably should not have done for my agenda: next to the well known PHPExcel class library, I’ve now also started something similar for PowerPoint: PHPPowerPoint.

    Just like with PHPExcel, PHPPowerPoint can be used to generate PPTX files from a PHP application. This can be done by creating an in-memory presentation that consists of slides and different shapes, which can then be written to disk using a writer (of which there’s currently only one for PowerPoint 2007).

    Simple PHPPowerPoint demo Here’s some sample code:

    /* Create new PHPPowerPoint object */
    $objPHPPowerPoint = new PHPPowerPoint();

    /* Create slide */
    $currentSlide = $objPHPPowerPoint->getActiveSlide();

    /* Create a shape (drawing) */
    $shape = $currentSlide->createDrawingShape();
    $shape->setName('PHPPowerPoint logo');
    $shape->setDescription('PHPPowerPoint logo');
    $shape->setPath('./images/phppowerpoint_logo.gif');
    $shape->setHeight(36);
    $shape->setOffsetX(10);
    $shape->setOffsetY(10);
    $shape->getShadow()->setVisible(true);
    $shape->getShadow()->setDirection(45);
    $shape->getShadow()->setDistance(10);

    /* Create a shape (text) */
    $shape = $currentSlide->createRichTextShape();
    $shape->setHeight(300);
    $shape->setWidth(600);
    $shape->setOffsetX(170);
    $shape->setOffsetY(180);
    $shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER );
    $textRun = $shape->createTextRun('Thank you for using PHPPowerPoint!');
    $textRun->getFont()->setBold(true);
    $textRun->getFont()->setSize(60);
    $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFC00000' ) );

    /* Save PowerPoint 2007 file */
    $objWriter = PHPPowerPoint_IOFactory::createWriter($objPHPPowerPoint, 'PowerPoint2007');
    $objWriter->save(str_replace('.php', '.pptx', __FILE__));

    Advanced sample A more advanced sample is also included in the download, where a complete presentation is rendered using PHPPowerPoint.

    Now go grab the fresh sample on CodePlex and be the very first person downloading and experimenting with it. Feel free to post some feature requests or general remarks on CodePlex too.

    I want to thank my employer, RealDolmen, for letting me work on this during regular office hours and also the people at DynamicLogic who convinced me to start this new project.


    Comments

    Doug Mahugh |

    Tuesday, May 05, 2009 1:05 AM

    trackback

    Links for 05/04/2009

    PHPPowerPoint 0.1.0 was released last week, as an open-source PHP API for generating PPTX files, much

    Comments are closed