Free Support Forum - aspose.com

Merging two large pdf documents to one takes LONG time

I am converting two large pdf documents one is 800,000 mb, the other is about half the size, 450,000mb into one one pdf. I am using code from example and its taking over 5 minutes to concatenate and its still not done yet.

Here is my function. I need to merge them, then pass the new file string path back to a web app to display the pdf in the browser.

Public Function MergePdfs(ByRef sfiles() As String) As String
Dim oNewPDF As Aspose.Pdf.Document
Dim sOutFile As String = “”
Dim iCnt As Int32 = 0
Dim sTicks As String = Now.Ticks.ToString

    Try
        'figure out the path to the files array
        If sfiles.Length > 0 Then
            If File.Exists(sfiles(0)) Then
                Dim oFile As FileInfo = New FileInfo(sfiles(0))
                sOutFile = Path.Combine(oFile.DirectoryName, (sTicks & ".pdf"))
                oFile = Nothing
                GC.Collect()
            End If



            For Each sFile As String In sfiles
                If iCnt = 0 Then
                    oNewPDF = New Aspose.Pdf.Document(sFile)
                End If
                iCnt += 1
                'open the pdf
                Dim openPdfFile As New Aspose.Pdf.Document(sFile)
                oNewPDF.Pages.Add(openPdfFile.Pages)
            Next

            oNewPDF.Save(sOutFile)
            Return sOutFile
        Else
            Return ""
        End If

        Return sOutFile
    Catch ex As Exception
        Throw
    Finally
        oNewPDF.Dispose()
        oNewPDF = Nothing
    End Try

End Function

@Goakes27

Thank you for contacting support.

Please update us if the merging process is completed successfully or some exception like OutOfMemoryException occurs, or if you have to kill the process after several minutes. Since both files exceed 1200 GB so large amount of memory and time will be required to carry out merging process. Can you please try to merge the files using Adobe Acrobat and then share your observations with us. Please also share your environment details with us so that we may investigate to help you out.

Hello,

the code does not end, and I have to kill the process.
I am also having issue reading a 2.1gb PDF into either aspose.pdf.document, or aspose.pdfFacade.pdfEditor.
I am needing to split this large file into smaller chunks.

@Goakes27

Would you please share two huge files that can reproduce this problem in our environment so that we may proceed to help you out.