Understanding the PDF file format – PDF image dpi

PDF Image dpi

Most elements of a PDF file are device independent Vector graphics. This means that they will always appear ‘smooth and clear’. By contrast images are bit-mapped. If the image is stretched it can appear pixellated. If the image is too small, it will be stretched and the pixels will become blocky. This happens when the image is of a low resolution.

There is a tradeoff here. The better quality, the bigger it (and the PDF) will be. That is why most PDF creation tools allow you to specify whether you are producing files for screen or printing. Printing benefits from better images but this means bigger files.

What you actually have with a PDF file is a raw image and a ‘scaling’ command to fit it into a slot on the page (the CTM matrix). If the raw image is bigger than the ‘slot’ you can zoom into the page and print it at high resolution. But there drawbacks. We saw a very large PDF file with raw images of 26,000 x 26,000 pixels which is rather excessive!

Combining the raw image size and the CTM does actually allow you to work out the image quality to decide how well the PDF file will scale and fit. Let me show you with an example. Imagine we have an image which is 585×585 pixels. It is shown on page with this CTM value.

(843 0 0)

(0 843 0)

(x y 1)

We can work out the dpi value with this formula

dpi =(int)(imageWidth/GraphicsStateValue*100);

This gives us a value of 69. This is reasonable for screen display (where 72 is the target figure) but not great for printing or for fine zooming. For printing, 300+ dpi should be the target.

We have added dpi calculations into our PDF viewer so you can get JPedal to do all the hard work of calculating the dpi with the 20th December release.

This post is part of our “Understanding the PDF File Format” series. In each article, we aim to take a specific PDF feature and explain it in simple terms. 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>