PHPOffice / PHPPresentation

A pure PHP library for reading and writing presentations documents
https://phpoffice.github.io/PHPPresentation
Other
1.31k stars 523 forks source link

Is it possible to generate .pptx file that can be themed/formatted in most PowerPoint Software? #803

Open foxxgreeley opened 5 months ago

foxxgreeley commented 5 months ago

I'm attempting to create a PowerPoint file that a user can download and then style (as in one-click theming/layout) in relevant PowerPoint software e.g. Google Slides, Microsoft PowerPoint, etc.

I've had success in creating/downloading the file but once it is in a relevant software the 'master slides' or theme of the slides does not affect the font color, style, or size when applied.

I've spent a few hours now searching and trying to see if I could somehow set a placeholder type and then fill it - but no dice. Is this even possible?

Here is the most simple example I could come up with that cannot be styled:

private function createSlides()
{
  // Create new PHPPresentation object
  $presentation = new PhpPresentation();

  // Create slide
  $slide = $presentation->createSlide();
  $slide->setName('Title of the slide');

  // Create a shape (text)
  $titleShape = $slide->createRichTextShape()
      ->setHeight(100)
      ->setWidth(600)
      ->setOffsetX(170)
      ->setOffsetY(100);
  $titleShape->getActiveParagraph()->createTextRun('This is a title.');

  return $presentation;
}