Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Small images can cause big problems in PDF files

1 min read

I debugged a file this week which showed up some interesting features you can find inside a PDF file. The actual problem was that a question mark was being displayed on an image. It should not appear there. Drilling down it turned out that it was actually drawn but the user could not see it because a white box was then drawn over it.

So the first point is that the data in some PDF files can be rather messy. Because the user only sees the final rendered output it is quite common to remove ‘old’ items by just drawing over them rather than actually erasing them from the data stream. This can cause issues with extraction because you need to check whether objects were actually visible. It also makes the file bigger.

The reason we did not erase the question mark was because the PDF stream was using a trick which involved creating a 1×1 pixel white image and then scaling it up to hide the question mark. I had written some heuristics to trim out tiny pixels which had not allowed for this case (it does now). It would have been more efficient to draw a white box but the PDF world if full of such little ‘tricks’.  So you need to look not just at the PDF commands but how they are being used to achieve an overall effect.

So watch out for these little ‘gotchas’ and if you are using our PDF viewer, it is fixed in today’s release.

This post is part of our “Understanding the PDF File Format” series. In each article, we discuss a PDF feature, bug, gotcha or tip. If you wish to learn more about PDF, we have 13 years worth of PDF knowledge and tips, so click here to visit our series index!



Can we help you to solve any of these problems?

IDRsolutions has been helping companies to solve these problems since 1999.

Convert PDF to HTML5 or SVG with BuildVuConvert PDF to HTML5 or SVGConvert AcroForms and XFA to HTML5 with FormVuConvert PDF forms to HTML5
Java Image SDK for working with Image files with JDeliJava SDK for Image files JPedal Java PDF SDK for working with PDF filesJava SDK for PDF files
Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2020. All rights reserved.