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.

Large images in PDF files (and why I think they are a bad idea)

1 min read

You can embed images in a PDF file as either Vector images or pixel images. This gives you huge power and flexibility, but (as with many things), the PDF file specification gives you these powers but not necessarily the wisdom to use them wisely.

I have been looking at a customer PDF which does not open in our Java PDF viewer (it does sometimes happen and then we jump on  the case). It turns out that this PDF file contains a very large bitmapped image (19,000 pixels by 12,000 pixels to be exact). This means you can scroll into it at great detail but most people are only going to see a very scaled version with most detail removed. And the bigger image is making the PDF file much bigger, even with with compression.

If we convert this into an image that is going to be a lot of memory (about 900 megs to hold the data if we include transparency, which we need for clipping). We can down-sample the image but there are no clues as to what would be the best down-sampled size to choose and how we should do the down-sampling.  In our viewer we can choose the viewable window but we are looking at PDF to HTML5 conversion here. We would either have to guess or need to adopt the strategy google maps uses and build lots of different tiled versions at different resolutions.

There are lots of different strategies which will produce different quality versions at different speeds.

If you want to have complex diagrams with the ability to scale in, the best format is to use Vector Graphics. This produces smaller, much better quality PDF files which use less memory. Do you agree with me? 

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!

Did you know...

IDRsolutions offers a whole range of online file converters to convert PDF and Microsoft Excel, Word and Office Documents to HTML5, SVG or image formats?

It is free to use for single file conversions and also includes Developer links if you want to use our commercial software for bulk conversions. Find out more on this page

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.

Leave a Reply

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

IDRsolutions Ltd 2020. All rights reserved.