Mark Stephens I have been working with Java and PDF since 1999 and am a big NetBeans fan. I enjoy speaking at conferences including Business of Software, JavaOne, CodeOne and DevFest. I have an MA in Medieval History and a passion for reading.

Interesting PDF bugs – zero bytes in a string

49 sec read

I have been looking at a PDF file which did not open in our Java Viewer. The issue turned out to be that we were misreading a rather crucial text string. In general, text values are defined in 2 ways:-

1. Encoded text characters (if it is WIN encoded it will look like standard text).

(this is a text stream)

2. Hex values (a set of 2 letter hex entries)

<01ff12>

The offending String (it is the /U value which is used to decrypt the file) initially looked like case 2 until I opened it up in a hex editor. The last part of the input includes a long stream of zero byte values until you then each the closing > tag.

 

 

 

 

The way to handle this appears to be to just ignore these values – I suspect they are there because the PDF creation library (ISIS information Systems according to the file) is writing out a fixed length string value. Easily fixed with a simple code tweak but it is a shame to find garbage which we then have to ignore.

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!

IDRsolutions develop a Java PDF Viewer and SDK, an Adobe forms to HTML5 forms converter, a PDF to HTML5 converter and a Java ImageIO replacement. On the blog our team post anything interesting they learn about.

Mark Stephens I have been working with Java and PDF since 1999 and am a big NetBeans fan. I enjoy speaking at conferences including Business of Software, JavaOne, CodeOne and DevFest. I have 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 2019. All rights reserved.