0

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

1 Answers1

1

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.

Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58
  • Thanks, I was expecting this functionality to appear inside the slide samples, I did found out how to achieve it by searching inside their API documentation and tracking down every used class and method. The difficult thing was to convert the colors that I was using from RGB to ARGB. –  Jun 18 '17 at 23:17
  • Yeah it is a shame it isn't mentioned in the documentation. Perhaps somebody should request it be added. – Sᴀᴍ Onᴇᴌᴀ Jun 18 '17 at 23:20
  • 1
    i wrote this $currentSlide = $objPhpPresentation->createSlide(); $oBkgColor = new Color(); $oBkgColor->setColor(new StyleColor(StyleColor::COLOR_DARKGREEN)); $currentSlide->setBackground($oBkgColor); and i get this error "Call to undefined method PhpOffice\PhpPresentation\Style\Color::setColor()" – Youssef Boudaya Oct 25 '18 at 16:29
  • @YoussefBoudaya If you have another question, please ask it by clicking the [Ask Question](//stackoverflow.com/questions/ask) button. – Sᴀᴍ Onᴇᴌᴀ Oct 25 '18 at 16:38
  • it's disabled for me that's why !! – Youssef Boudaya Oct 26 '18 at 08:12
  • Please don't ask questions in comments. [Ask a new question here](https://stackoverflow.com/questions/ask) and mention this post as related. – Sᴀᴍ Onᴇᴌᴀ Oct 26 '18 at 14:23
  • "You have reached your question limit" – Youssef Boudaya Oct 26 '18 at 15:23
  • If you haven't already read it, check out [this meta post](https://meta.stackexchange.com/q/86997/341145) – Sᴀᴍ Onᴇᴌᴀ Oct 26 '18 at 15:28