Did you know that not only can you convert PDF files into images, (as I explained last time), but you can also extract the actual images used on the page. In this post, I am going to tell you more…
How are images stored in PDF files?
First, you need to understand how images are stored in a PDF file. A PDF contains a raw image (which may be much better quality than the the scaled version displayed), a transformation (which can scale, sheer, rotate, stretch the image), and a clip (which may remove parts of the image).
We can make use of all this when we extract the images from the PDF file. More information about understanding this can be found in our previous blog post. A classic use for this is extracting high quality images of products from existing catalogues for your online store (or all those cute kitten pictures from that PDF you downloaded).
The image data is not stored in PDFs as an image such as a JPG, PNG, TIFF etc. Instead images are stored as XObjects within the file, which contain information about the image. The binary data used for the pixels,the colorspace information, clipping are all separate and ‘merged’ together to create the final image when the PDF is displayed. Further details about this can be found in our previous article on how images are stored in PDF files.
Find out more about image extraction from the PDF
In our JPedal library, we have already done all the hard work of making it possible to extract images from PDFs. We also have lots of example code and documentation on image extraction to get you started. And if you just want to extract the clipped image, we have an option for that too.
Next time we will take a look at some further reading you can do on PDF & Java.
Latest posts by Bethan Palmer (see all)
- How we use Basecamp to manage and communicate - July 18, 2017
- How we have used close.io to improve our sales operation - July 13, 2017
- 3 reasons we will be attending DevFest Istanbul 2017 - June 29, 2017
- Java 9 Articles – Series Index - June 14, 2017
- 5 reasons we will be attending Business of Software USA 2017 - June 14, 2017