Error Processing Presentation OrderedMergeRequest: Local File Not Found

Hi there,
I have the following code:

Imports System.IO
Imports Aspose.Slides.Cloud
Imports Aspose.Slides.Cloud.Sdk
Imports Aspose.Slides.Cloud.Sdk.Model

Public Function fcMergePPTVersionCloudAspose(ByVal SourcePPT As String, ByVal TargetPPT As String, ByVal FinalPPT As String, ByVal NamaFileOnly As String) As String
    Dim ResultText As String
    ResultText = "SUCCESS"

    Try
        Dim api As SlidesApi = New SlidesApi("xxxxxx", "xxxxxx")
        Dim fileInfo = New Sdk.FileInfo With {
            .Content = File.OpenRead(SourcePPT),
            .Name = NamaFileOnly.Replace(".pptx", "_1.pptx")
        }
        Dim fileInfo2 = New Sdk.FileInfo With {
            .Content = File.OpenRead(TargetPPT),
            .Name = NamaFileOnly.Replace(".pptx", "_2.pptx")
        }
        Dim files = New List(Of Sdk.FileInfo) From {
            fileInfo,
            fileInfo2
        }
        Dim presentation1 = New PresentationToMerge With {
            .Path = SourcePPT,
            .Slides = New List(Of Integer) From {
                1,
                2
            }
        }
        Dim presentation2 = New PresentationToMerge With {
            .Path = TargetPPT,
            .Slides = New List(Of Integer) From {
                1,
                2
            }
        }
        Dim request = New OrderedMergeRequest()
        request.Presentations = New List(Of PresentationToMerge) From {
            presentation1,
            presentation2
        }

        Dim resultStream = api.MergeOnline(files, request)


        Dim outputStream = File.Open(TargetPPT, FileMode.Create)

        resultStream.CopyTo(outputStream)
    Catch ex As Exception
        ResultText = "error:" & ex.Message
    End Try
    Return ResultText
End Function

But it always gave me the following exception:

{“Error processing presentation OrderedMergeRequest: file C:\xxxx_1.pptx not found”}

What did I do wrong?

Thank you

Eko

@eko.radesna,
Thank you for contacting support.

The error occurs because the value of fileInfo.Name property isn’t equal to the value of the presentation1.Path property. The same problem exists for the fileInfo1.Name and presentation2.Path properties.

Please try using the following code example:

Public Function fcMergePPTVersionCloudAspose(ByVal SourcePPT As String, ByVal TargetPPT As String, ByVal FinalPPT As String) As String
    Dim ResultText As String
    ResultText = "SUCCESS"

    Try
        Dim api As SlidesApi = New SlidesApi("xxxxxx", "xxxxxx")

        Dim fileInfo = New Sdk.FileInfo With {
            .Content = File.OpenRead(SourcePPT),
            .Name = "first" ' you can use any name here
        }

        Dim fileInfo2 = New Sdk.FileInfo With {
            .Content = File.OpenRead(TargetPPT),
            .Name = "second" ' use a different distinguished name here
        }

        Dim files = New List(Of Sdk.FileInfo) From {
            fileInfo,
            fileInfo2
        }

        Dim presentation1 = New PresentationToMerge With {
            .Path = fileInfo.Name, ' use the same name of the first file for a reference
            .Slides = New List(Of Integer) From {
                1,
                2
            }
        }

        Dim presentation2 = New PresentationToMerge With {
            .Path = fileInfo2.Name, ' use the same name of the second file for a reference
            .Slides = New List(Of Integer) From {
                1,
                2
            }
        }

        Dim request = New OrderedMergeRequest()
        request.Presentations = New List(Of PresentationToMerge) From {
            presentation1,
            presentation2
        }

        Dim resultStream = api.MergeOnline(files, request)
        Dim outputStream = File.Open(FinalPPT, FileMode.Create)

        resultStream.CopyTo(outputStream)
    Catch ex As Exception
        ResultText = "error:" & ex.Message
    End Try
    Return ResultText
End Function
End Module

Merge Presentations from Various Sources into a Local File|Documentation

Hi Andre,

Thank you for the fast and response.

The solution works for source and target files with less than 6 slides, when I tried with a 10 slides source and target files, it gives me the following error :

Slide index 7 is out of bounds. Valid index range is between 1 and 6.

Is there any limitation on how much slides can be merged online?

Best regards,

Eko

@eko.radesna,
Typically this error occurs when you specify a slide index that is greater than the number of slides.

Hi Andre,

My bad, it was indeed I didn’t check the right slide index.

Thanks

Eko

@eko.radesna,
You can check the number of slides in a presentation using the GetSlides method but the presentation must be saved in the storage.
Get the Number of Slides|Documentation