PHPPresentation
PHPPresentation copied to clipboard
can't merge 2 pptx files
Hi, I can't merge two pptx files into one. The result pptx has all slides in blank. Here is my code:
$oPHPPresentation = new PhpPresentation();
$oReader1 = IOFactory::createReader('PowerPoint2007');
$oPHPPresentation1 = $oReader1->load(storage_path('app/diapositiva1.pptx'));
$c = $oPHPPresentation1->getSlideCount();
for($i=0; $i<$c; $i++)
$oPHPPresentation->addExternalSlide($oPHPPresentation1->getSlide($i));
$oReader2 = IOFactory::createReader('PowerPoint2007');
$oPHPPresentation2= $oReader2->load(storage_path('app/diapositiva2.pptx'));
$c = $oPHPPresentation2->getSlideCount();
for($i=0; $i<$c; $i++)
$oPHPPresentation->addExternalSlide($oPHPPresentation2->getSlide($i));
$oWriterPPTX = IOFactory::createWriter($oPHPPresentation, 'PowerPoint2007');
$oWriterPPTX->save(storage_path("app/merged.pptx"));
any update on this? lost most of the formatting when I tried to read previously generated pptx by phpPresentation
@delia-curiel or @dookieffs Have you got two pptx in error to share ?
I've the same problem.
This code should do the job:
$ppt_reader = IOFactory::createReader('PowerPoint2007');
// Create destination and add all slides.
$destination = new PhpPresentation();
// The first slide is empty as it's added on the create operation.
$destination->removeSlideByIndex(0);
foreach ($this->souce_slides as $souce_slide) {
$file = drupal_realpath($souce_slide);
$sourceSlideShow = $ppt_reader->load($file);
foreach ($sourceSlideShow->getAllSlides() as $oSlide) {
$destination->addExternalSlide($oSlide);
}
}
$xmlWriter = IOFactory::createWriter($destination, 'PowerPoint2007');
Even with just one pptx file, the result doen't have some text boxes.