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.

Understanding the PDF file format – PDF image dpi

1 min read

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!

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.