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

Notes in pptx gives error on reader #751

Open Offbeatmammal opened 1 year ago

Offbeatmammal commented 1 year ago

if I have an Office365 edited PPTX with no notes, I am able to open and enumerate the slides with no issue. if however I have notes on the slides I get the error below.

Able to repro using the sample_12.pptx from here (before works fine, add a simple letter to the Notes on slide1 and it breaks. removing the Note doesn't help).

require_once 'vendor/autoload.php';
use PhpOffice\PhpPresentation\IOFactory;

$oReader = \PhpOffice\PhpPresentation\IOFactory::createReader('PowerPoint2007');
$oPresentation04 = $oReader->load('Sample_12.pptx');

Fatal error: Uncaught TypeError: PhpOffice\PhpPresentation\Reader\PowerPoint2007::loadShapeRichText(): Argument #3 ($oSlide) must be of type PhpOffice\PhpPresentation\Slide\AbstractSlide, PhpOffice\PhpPresentation\Slide\Note given, called in C:\AP-Web\engine-word\vendor\phpoffice\phppresentation\src\PhpPresentation\Reader\PowerPoint2007.php on line 1375 and defined in C:\AP-Web\engine-word\vendor\phpoffice\phppresentation\src\PhpPresentation\Reader\PowerPoint2007.php:888 Stack trace:

0 C:\AP-Web\engine-word\vendor\phpoffice\phppresentation\src\PhpPresentation\Reader\PowerPoint2007.php(1375): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadShapeRichText(Object(PhpOffice\Common\XMLReader), Object(DOMElement), Object(PhpOffice\PhpPresentation\Slide\Note))

1 C:\AP-Web\engine-word\vendor\phpoffice\phppresentation\src\PhpPresentation\Reader\PowerPoint2007.php(755): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadSlideShapes(Object(PhpOffice\PhpPresentation\Slide\Note), Object(DOMNodeList), Object(PhpOffice\Common\XMLReader))

2 C:\AP-Web\engine-word\vendor\phpoffice\phppresentation\src\PhpPresentation\Reader\PowerPoint2007.php(369): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadSlideNote('notesSlide1.xml', Object(PhpOffice\PhpPresentation\Slide))

3 C:\AP-Web\engine-word\vendor\phpoffice\phppresentation\src\PhpPresentation\Reader\PowerPoint2007.php(169): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadSlides('<?xml version="...')

4 C:\AP-Web\engine-word\vendor\phpoffice\phppresentation\src\PhpPresentation\Reader\PowerPoint2007.php(136): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadFile('Sample_12.pptx')

5 C:\AP-Web\engine-word\pptx_read.php(6): PhpOffice\PhpPresentation\Reader\PowerPoint2007->load('Sample_12.pptx')

6 {main}

thrown in C:\AP-Web\engine-word\vendor\phpoffice\phppresentation\src\PhpPresentation\Reader\PowerPoint2007.php on line 888

Offbeatmammal commented 1 year ago

looks like this might be a dupe of https://github.com/PHPOffice/PHPPresentation/issues/710 - are there any plans to pull the suggested fix?

Offbeatmammal commented 1 year ago

following these fixes did allow the PPTX to be opened, but unable to successfully read the notes in the opened file, and using it as a source for addExternalFile results in an output in need of repair :(