Why Convert PDF Files to Image?
Images are non-editable, pixelate, are larger and non-searchable. So why would you want to convert PDF files to images?
The answer is that you might not want to display your file with PDF display tools. You might want to display the content in a browser (one increasingly popular solution to this is our PDF to HTML5 converter). Or you might want to use an image of the PDF file as a thumbnail.
These two use cases require different size images. So one of the things we needed to consider with PDF2Image was, how big to make the output?
There has to be a balancing act when choosing the size of the image output. If it is too large, more memory will be used and the conversion will take longer. Therefore our default mode is to convert the image to the size of a PDF file. This is what our example conversion does. But some people might want a larger image, which will have more detail and allow you to zoom in and retain the quality. Therefore we also have an option to convert pages to hi res images. For files with high-quality images, the time and memory increase might be worth the trade-off. You can read more about this in our previous article on PDF to image conversion in Java.
More information about how we overcame the problem of retaining image quality can be found in our article about PDF to image quality. If you have read this you will know that the PDF file format often uses vector graphics, and converting to bitmap can result in a loss of quality. This is because a line cannot be half a pixel wide, it can only be on or off. We have different solutions to this problem depending on the use case. Each comes with a compromise. For example, scaling up the image output will give a higher quality result, but will use more time and memory.
So there is a range of possible factors to consider when converting PDF to image. Our library comes with extensive documentation to enable you to choose the most appropriate solution.
If you found this article useful, why not check out this video tutorial in how to read and write TIFF files in Java with JDeli