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