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)
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!
Latest posts by Mark Stephens (see all)
- 4 ways Companies can make remote working successful - December 21, 2017
- My experience of a Turkish bath (visiting Istanbul for DevFest) - November 24, 2017
- My 5 key takeaways from JavaOne 2017 - October 6, 2017
- My notes and pictures from thursday JavaOne 2017 - October 5, 2017
- My notes and pictures from Wednesday JavaOne 2017 - October 5, 2017