I have the binary for several pdf files stored in a collection of Byte arrays.
My goal is to concatenate them into a single .pdf file using abcpdf, then stream that newly created file to the Response object on a page of an ASP.Net website.
Had been doing it like this:
BEGIN LOOP ...
'Create a new Doc
Dim doc As Doc = New Doc
'Read the binary of the current PDF
doc.Read(bytes)
'Append to the master merged PDF doc
_mergedPDFDoc.Append(Doc)
END LOOP
Which was working fine 95% of the time. Every now and then however, creating a new Doc object would throw a System.ExecutionEngineException and crash the CLR. It didn't seem to be related to a large number of pdfs (sometimes would happen w/ only 2), or with large sized pdfs. It seemed almost completely random.
This is a known bug in abcpdf described (not very well) here Item 6.24. I came across a helpful SO post which suggested using a Using block for the abcpdf Doc object.
So now I'm doing this:
Using doc As New Doc
'Read the binary of the current PDF
doc.Read(bytes)
'Append to the master merged PDF doc
_mergedPDFDoc.Append(doc)
End Using
And I haven't seen the problem occur again yet, and have been pounding on a test version as best as I can to get it to.
Has anyone had any similar experience with this error? Did this fix it?