My application is generating PDF documents using itext#. The files open fine and display correctly in Foxit Reader but in Adobe Acrobat it errors with:
There was an error processing page. There was a problem reading this document (109).
Why will the file open in one but not the other?
This was my code:
var document = new Document(_pageSize, PageMargin, PageMargin, PageMargin, PageMargin);
var writer = PdfWriter.GetInstance(document, output);
writer.CloseStream = false;
writer.PageEvent = new Footer(HeaderFont, _defaultFont.BaseFont, report.Name);
document.Open();
if (report.Results.Any())
document.Add(CreateTable(report.Results, report.Types, report.RootType));
else
document.Add(new Paragraph("No results", _defaultFont));
writer.Close();
After adding the line document.Close(); before the writer.Close(); line, it now shows in both Foxit and Acrobat.
I guess a key thing with itext# is to be very careful that objects are closed properly. This probably reflects it is a ported library and not a library built for .NET from the ground up.
Some pdf readers are more tolerant in various areas than others. Foxit probably ignores bits in a pdf that it doesn't support. Different versions of acrobat choke on different things, just to muddy the waters. Without seeing the PDF in question, all we've got is guesswork.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With