Reputation: 10263
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?
Upvotes: 3
Views: 2936
Reputation: 10263
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.
Upvotes: 7
Reputation: 15868
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.
Upvotes: 2