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.

Interesting PDF bugs – values out of range

54 sec read

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 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 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.

Enabling SVG Gzip Compression on Apache and NGINX

Gzip compression is a widely supported method of reducing the size of the content sent from a web server in order to improve the...
Leon Atherton
47 sec read

Leave a Reply

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

IDRsolutions Ltd 2019. All rights reserved.