CristalTeam / pptx

🎞️ Copy, move, merge and template Powerpoint files (.pptx) using PHP
MIT License
23 stars 7 forks source link

Layout information is lost for added slides #5

Open jschiedt opened 4 years ago

jschiedt commented 4 years ago

I open a pptx with a layout containing a background image using $basePPTX = new PPTX($path1); and save it $basePPTX->saveAs($path2);

everything is fine.

I add the same pptx again: $endPPTX = new PPTX($path1); $basePPTX->addSlides($endPPTX->getSlides());

I get a message, if I want to repair the pptx, then I get a message, that certain slides cannot be displayed. for other slides no layout exists.

if I add different presentations I get the same messages, but only layouts are missing for the added slides.

do you have any idea?

TZK- commented 4 years ago

We've added bug report issue template to ease helping. Can you edit your message to follow the new template ?

Thanks

jschiedt commented 4 years ago

PHP-Code: $basePPTX = new PPTX('/var/www/html/test.pptx'); $endPPTX = new PPTX('/var/www/html/test.pptx'); $basePPTX->addSlides($endPPTX->getSlides()); $basePPTX->saveAs('/var/www/html/result.pptx');

PPTX-Files: test.pptx result.pptx

Expected behavior: PPTX will open and display 4 slides

Actual behavior: Error message when opening file: Bildschirmfoto 2020-10-12 um 14 03 19

Error message after klicking on yes (repair file) Bildschirmfoto 2020-10-12 um 14 03 56

Added slides have no background: Bildschirmfoto 2020-10-12 um 14 04 17

Linux 3.10.0-693.11.6.el7.x86_64 #1 SMP Thu Jan 4 01:06:37 UTC 2018 x86_64 PHP Version 7.1.33 PowerPoint2007

alexcrowdhub commented 3 years ago

Has anyone found a resolution to this issue? Currently seeing the same thing

abarrett86 commented 3 years ago

@TZK- Have you been able to look into this issue?

camillebaronnet commented 3 years ago

@TZK- and I don't have enough time to fix this problem as quickly as possible. Any help is welcome

abarrett86 commented 3 years ago

Thank you for your response; do you have any idea what would cause this issue? I'm searching for a solution now but any clues would be appreciated

camillebaronnet commented 3 years ago

Thank you too,

Maybe the file reference (.rels) is missing in an XML file. Sometimes it is possible to repair the PPTX generated with Powerpoint. In this case it' s interesting to compare the file fixed by powerpoint with the one generated by the lib.

Also, to prevent some incompatibility, we have deliberately blocked the copy of certain reference, it is perhaps this one that poses a problem today.

Have a look at /Presentation/Resource/Presentation.php and /Presentation/Resource/Slide.php at 155.

Thank you in advance

jbreitenthaler commented 3 years ago

I am currently experiencing the same problem, has anybody made some progress yet?

One thing I already discovered when comparing the version of the file that Powerpoint fixed with the original merged file, was the very different assignment of rIDs. Another thing which does not work on my machine is the generation of unique IDs for the master slides (too big for 32-bit integer, floats do not seem to work), anybody else had that problem in this context?

abarrett86 commented 3 years ago

I couldn't find any fixed by editing the library files, but what did work for me is to open the source ppt file in powerpoint and run the File > Inspect option, then fix anything it found. This included : removing notes by clicking the remove button on the tool, removing external documents (most often by rasterizing charts and using a picture rather than the actual chart), removing hidden content by clicking the remove button on the tool. Once I did this everything seemed to work with the library.

A few additional notes:

Hope this helps, Good Luck!

jbreitenthaler commented 3 years ago

Thanks @abarrett86 but your solution did not work for us unfortunately. I put in some work and compared the presentation fixed by Powerpoint with the generated one (simply merging two presentations with one empty slide each). I did the comparison by replacing the fixed files in the archive with the damaged ones one by one and these were the changes not accepted by Powerpoint (repair dialogue showing up again):

I don't know if just referencing new slides to the original master is a possible feature, but adding a whole new set of master slides everytime slides are added to a presentation seems weird to me as with the features this library offers I think most people are going to want to merge PPTs with the same Master.

We are currently using a workaround which works fine but my company can not put the time in to fix the library code ourselves, but we would appreciate a fix in the near future so we can use your library as intended. @camillebaronnet @TZK-