PHPOffice / PHPPresentation

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

Unable to read slide note #326

Open jasonhuhx opened 7 years ago

jasonhuhx commented 7 years ago

I am trying to read slide note from an external .pptx file, however unable to do so. The slideNote property inside PhpOffice\PhpPresentation\Slide\SlideLayout is always null.

Here is my code trying to retrieve note text from a slide

$pptReader = IOFactory::createReader('PowerPoint2007');
$oPHPPresentation = $pptReader->load('Sample_09_SlideNote.pptx');
$slide = $oPHPPresentation->getSlide(0);
var_dump($slide->getNote()->getShapeCollection()); // empty array

Sample_09_SlideNote.pptx

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/42370931-unable-to-read-slide-note?utm_campaign=plugin&utm_content=tracker%2F323104&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F323104&utm_medium=issues&utm_source=github).
Progi1984 commented 7 years ago

@jasonhuhx Could you test the develop branch ? Normally, it's done for PowerPoint2007 & PowerPoint97.

jasonhuhx commented 7 years ago

@Progi1984 Confirmed working for PowerPoint2007. Here is my code to retrieve plain text from slide notes:

$pptReader = IOFactory::createReader('PowerPoint2007');
$oPHPPresentation = $pptReader->load('Sample_09_SlideNote.pptx');

$slide = $oPHPPresentation->getSlide(0);
foreach ($slide->getNote()->getShapeCollection() as $shape) {
  foreach ($shape->getParagraphs() as $paragraph) {
    var_dump($paragraph->getPlainText());
  }
}

However I'm untable to test PowerPoint97 because the following code is giving me error PowerPoint97 Reader : readRecordOfficeArtSpgrContainer.

$pptReader = IOFactory::createReader('PowerPoint97');
$oPHPPresentation = $pptReader->load('Sample_09_SlideNote.ppt');

The .ppt file I'm using is converted down from .pptx, on PowerPoint for Mac.

Sample_09_SlideNote.ppt.zip

Progi1984 commented 7 years ago

PR #342