phpbackground-colorphppresentation

How to change the background color for a PHPPresentation Slide?


I've recently started to work with the PHPPresentation library to create Powerpoint presentations. I need to change the background color of certain slides, I looked over the code samples that they offer and inside the developer documentation, they both lack this vital information.

https://github.com/PHPOffice/PHPPresentation/tree/develop/samples http://phppresentation.readthedocs.io/en/latest/slides.html


Solution

  • I downloaded the repository from github and searched for 'background'. There were quite a few results, both in samples and the source code.

    One example is Sample 15. Below is an excerpt from lines 14-23:

    // Create slide
    echo date('H:i:s') . ' Create slide'.EOL;
    $oSlide1 = $objPHPPresentation->getActiveSlide();
    $oSlide1->addShape(clone $oShapeDrawing);
    $oSlide1->addShape(clone $oShapeRichText);
    // Slide > Background > Color
    $oBkgColor = new Color();
    $oBkgColor->setColor(new StyleColor(StyleColor::COLOR_DARKGREEN));
    $oSlide1->setBackground($oBkgColor);
    

    It appears that method setBackground() is defined in AbstractSlide.php at line 349 as of revision d07784c.