PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Error when empty object encountered + patch
http://forum.pdfsharp.com/viewtopic.php?f=3&t=3451
Page 1 of 1

Author:  Gerben Vos [ Thu Sep 08, 2016 7:48 pm ]
Post subject:  Error when empty object encountered + patch

PdfSharp gives an error when an object is empty (e.g., "14 0 obj endobj"). This is indeed invalid PDF, but Acrobat does not complain about it at all, so it should be handled.

This may result in the following error message:
- Unexpected token 'endobj' in PDF stream. (lzw.pdf)

Fixed by treating empty objects the same as null objects.

Discussion: this happens because PdfSharp tries to read all objects when opening the PDF (while parsing the xref tables). I think this is not really such a good idea, as it loads a lot of data into memory, not all of which may be used. Also, it seems to me that PDF has been designed to be easy to "lazy load", so why not do it? Is there some reason inside PdfSharp why this is done?

Patch attached.

Attachments:
lzw.zip [110.92 KiB]
Downloaded 277 times
pdfsharp-690.zip [463 Bytes]
Downloaded 277 times

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/