@navdeep.singh,
Thank you for your patience.
In this case, you shouldn’t use the mergeOnline
method.
First, you need to upload each file as shown below:
$fileStream = fopen($inputFolder . $fileName1, 'r');
$slidesApi->uploadFile($fileName1, $fileStream);
$fileStream = fopen($inputFolder . $fileName2, 'r');
$slidesApi->uploadFile($fileName2, $fileStream);
Then you can create an empty presentation file for result (first make sure for yourself that a file with $outputFileName
name does not exist):
$slidesApi->createPresentation($outputFileName);
$deleteRequest = new Requests\DeleteSlidesCleanSlidesListRequest($outputFileName, array(1));
$slidesApi->deleteSlidesCleanSlidesList($deleteRequest);
Then you have to merge these files the next way:
$mergeList = new Model\PresentationsMergeRequest();
$mergeList->setPresentationPaths(array($fileName1, $fileName2));
$mergeRequest = new Requests\PostPresentationMergeRequest($outputFileName, $mergeList);
$slidesApi->postPresentationMerge($mergeRequest);
Then you can download the output presentation file like this:
$result = $slidesApi->downloadFile($outputFileName);
$fileSize = $result->getSize();
$contents = $result->fread($fileSize);
file_put_contents($outputFolder . $outputFileName, $contents);
Finally, you can convert and download the result to PDF format as shown below:
$result = $slidesApi->downloadPresentation($outputFileName, Model\ExportFormat::PDF);
$fileSize = $result->getSize();
$contents = $result->fread($fileSize);
file_put_contents($outputFolder . $pdfFileName, $contents);
Note 1: You have to define the variables $inputFolde
r, $outputFolder
, $fileName1
, $fileName2
, $outputFileName
, $pdfFileName
.
Note 2: I didn’t use a storage. Please try to do it yourself. If you fail, I will try to help you.
We will improve our documentation. We apologize for any inconvenience caused.
Sources: SlidesApi.