We were sent a PDF file last week which was slow and needed a lot of memory to decode. We investigated the file and found that it contained a huge image (6000×6000 pixels). The image data for this was encoded so it meant a big hit decompressing the data, then assembling the image before down-sampling it to appear on an 595×842 page.
Sometimes it is useful to have a large image, because you can then zoom in. But this would need a zoom of 750% to make full use of it. And it turned out it was actually a white box drawn on the screen for background. So you could actually have used a 1×1 pixel image to achieve the same thing.
So if you have control over your PDF files, ask yourself, do I need images that big or is it just bloat?
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!
Do you need to write or read JPEG in Java?
We have an easy guide on how to write JPEG in Java using ImageIO and JDeli.
You can learn how to read/write most of the image files in ImageIO. However, it gives little control over the process.
JDeli is easy to use and offers complete support, so why don't you give a try?