Merge PowerPoint Presentations in PHP using Aspose.Slides REST API fails randomly

Hi @Andrey_Potapov
I am getting this random issue while merging pptx files:
image.png (58.8 KB)

It is a random issue. If I try again 2-3 times, it works and gives success message as following:
image.png (19.0 KB)

And if I try again it gives the issue. So it is random. Can you please check?

This is the code that I am using: test.zip (505 Bytes)

Thanks

@navdeep.singh,
I tested your code example (50 iterations in a loop time and again) and found no errors. Could you share the presentation files that can be used to reproduce the error on our side, please?

Note: Please don’t public your Client Id and Client Secret in the future (I removed them from your zip archive).

Documents: Merge PowerPoint Presentations

Thanks @Andrey_Potapov These are the files: files.zip (1.8 MB)

The issue happens with all types of files. I have tried with other files also. It is random.

Also @Andrey_Potapov can you please tell me how can I merge 2 pptx files and and then convert the output to PDF.

I see there is mergeOnline method which merges and returns the output.
But in order to convert I have to use:
$request = new Requests\PostSlidesConvertRequest($file, Model\ExportFormat::PDF);

which again posts the file on storage (the file is already there because I merged 2 pptx files). Is there any way I can convert a file to PDF which is already in storage and download it?

So the thing is I want to merge 2 pptx files and download the final pptx file and also it’s PDF.

Thanks

@navdeep.singh,
Thank you for the presentation files. I reproduced the error and logged the issue with ID SLIDESCLOUD-1201 in our tracking system. Our development team will investigate this case. I will inform you of any progress.

I will answer your other questions later. Thank you for your patience.

@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 $inputFolder, $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.

Hi @Andrey_Potapov Thanks I will check this. Can you please provide an update on the bug?

@navdeep.singh,
I requested some news of this issue from our development team. I will let you know as soon as possible.

@navdeep.singh,
Our development team is working on the issue.

@Andrey_Potapov Thanks for the update.

Hi @Andrey_Potapov,

Hope you are doing well!

Can you please provide an update on this issue?

Thanks

@navdeep.singh,
A fix has been added to Aspose.Slides Cloud 21.4. Please check it on your side.

Hi @Andrey_Potapov Do I need to download from here GitHub - aspose-slides-cloud/aspose-slides-cloud-php: PHP library for communicating with the Aspose.Slides Cloud API ? or is there any other link?

I have downloaded from GitHub - aspose-slides-cloud/aspose-slides-cloud-php: PHP library for communicating with the Aspose.Slides Cloud API and checking. Will let you know if I still face issue, Thanks

@navdeep.singh,
You don’t need to do any updates.