PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Oct 20, 2017 9:26 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Sep 08, 2016 7:32 pm 
Offline

Joined: Tue Aug 02, 2016 9:56 am
Posts: 36
Location: Amsterdam, The Netherlands
PdfSharp does not do a proper scan for the end of an inline image in a content stream, but instead scans for an 'E' character followed by an 'I' character. (EI is the end-of-image token). Actually, the PDF spec is underspecified in this case, as it does not provide well-defined criteria for when the inline image data ends, so all implementations need a bit of guesswork.

Depending on the inline image data, this can result in one of these error messages:
- Unexpected character '0x00a5' in content stream. ('0x00a5' may be a different value) ( http://www.stillhq.com/pdfdb/000351/data.pdf )
- The given key was not present in the dictionary. (found in confidential client PDFs only, sorry)

Resolved by scanning for <whitespace>EI<whitespace> instead of just EI. This works well for all encountered PDFs. Also, I had a peek at the iText implementation, and they do the same (except that in cases where they can determine the exact length of the inline image data from its metadata, they use that instead; but that is very uncommon, as most inline images, including all which I encountered, are compressed).

Also added extra checks for EOF (untested).

Patch attached.


Attachments:
pdfsharp-688.zip [593 Bytes]
Downloaded 84 times

_________________
Gerben Vos
Developer, ZyLAB Technologies B.V.
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group