php - How to change the background color for a PHPPresentation Slide?


Keywords:php 


Question: 

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.


1 Answer: 

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.