I am trying to merge multiple PDFs into a new document using the following code:
Public Function MergeAsByteArray(pdfFiles As List(Of String)) As Byte()
Using document = New PdfDocument()
For Each fileName In pdfFiles
Using source = PdfDocument.Load(fileName)
document.Pages.Kids.AddClone(source.Pages) ' BLOWS UP HERE
End Using
Next
Using msPDF As New MemoryStream
document.Save(msPDF)
Return msPDF.ToArray
End Using
End Using
End Function
The code blows up on the document.Pages.Kids.AddClone(source.Pages)
line with “Array item is not indirect object”. The exception contains a help link.
This happens on very few documents - mostly very large ones. Why am I getting this error?
Using GemBox.Pdf 1.3 for .NET Standard 2.0. The dll version is 13.0.200.1052