I have been looking at an interesting Customer PDF today which highlights some of the ‘issues’ you can get with a PDF file, allegedly create with Adobe Web Capture 9.0. The issue was that some of the content was not displayed.
Drilling down I found that the error was caused by this code (I have added comments in brackets to explain what the code does).
-0.074509 g (set colour to a value between 0 and 1)
134 14 m
134 1 l
1 1 l
2 2 l
133 2 l
133 13 l (define a rectangle)
f (draw as filled shape onscreen)
You can hopefully see the problem. The PDF reference says that the g command takes a value between 0 and 1, but we have a value outside the range. This makes it much harder to write a PDF library because you have to bullet-proof every routine to allow for unexpected values and take everything in the spec with a certain amount of skepticism.
So the correct definition of the g command should be that it ‘expects a value between 0 and 1 but anything might turn up and so you should use 0 and 1 as the min and max values‘.
Do you have any PDF ‘features‘ which really annoy you? Maybe we could have a ‘strict’ mode in PDF version 2.0
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 library, a PDF forms to HTML5 converter, a PDF to HTML5 or SVG converter and a Java Image Library that doubles as an ImageIO replacement. On the blog our team post about anything interesting they learn about.