Interesting PDF bugs – values out of range

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!

Related Posts:

The following two tabs change content below.

Mark Stephens

System Architect and Lead Developer at IDRSolutions
Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.
Markee174

About Mark Stephens

Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.

He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>