My requirement is to split ppt/pptx files and then merge particular slides.
I have successfully split ppt/pptx files into seperate slides using PHP COM. Now I want to join/merge the slides using some PHP Library.
However, there doesn't seem to be one except PHPPowerpoint.
I can use PHPPowerpoint to create slides and add text nodes/images using it but it cannot read existing .ppt/pptx files and create a merged output.
Is there another way? I will appreciate any help at all.
EDIT:
I was able to merge slides but not Properly.. the background color/sort order is still missing. Please help as there are no references on the web on this except for this link -
http://msdn.microsoft.com/en-us/library/office/ff746640%28v=office.15%29.aspx
Here is the code -
//SET Max exec time
ini_set("max_execution_time",-1);
$directory = 'c:/ppt/slides/';
$files_list = array_diff(scandir($directory,SCANDIR_SORT_DESCENDING), array('..', '.')); //Get list of all files from the sub slides folder
//var_dump($files_list); die;
$ppt_new = new COM("powerpoint.application") or die("Unable to instantiate Powerpoint 2");
$ppt_new->Presentations->Add(true); //Create the new(merged) ppt
$dirpath = "C:/ppt/slides/";
$ppt_new->Presentations[1]->Slides->Add( 1, 1 );
foreach($files_list as $file) { //Loop through all slides to merge those
$powerpnt = new COM("powerpoint.application") or die("Unable to instantiate Powerpoint");
echo "Adding slide...";
echo $file_path1 = realpath($dirpath.$file);
$pres = $powerpnt->Presentations->Open($file_path1, false, false, false) or die("Unable to open the slide");
echo $count = (int)$pres->Slides->Count."<--SLIDES COUNT<br>";
$i=1;
foreach($pres->Slides as $slide)
{
try {
$pptLayout = $slide->CustomLayout;
// var_dump($pptLayout); die;
// $ppt_new->Presentations[1]->Slides[$i]->FollowMasterBackground = false;
// $ppt_new->Presentations[1]->Slides[$i]->Background = $slide->Background;
//$ppt_new->Presentations[1]->Slides->Layout = $pptLayout;
$ppt_new->Presentations[1]->Slides->InsertFromFile($file_path1, $i, $i, $i);
// $ppt_new->Presentations[1]->SaveAs("merged11.ppt");
// $ppt_new->Export("created.ppt", "ppt");
$i++;
}
catch(Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "\n";
}
}
}
//Save the merged presentation
$powerpnt->quit();
$ppt_new->Presentations[1]->SaveAs("c:\ppt\merged121.ppt");
$ppt_new->Presentations[1]->Close();
$ppt_new->quit();
echo "Done!";
Can anyone please run the code and find why the background is not coming in the merged slide?
Thanks already.