Details
Description
I have a process that needs to convert pages of pdf files to images to be able to detect barcodes.
Since I've upgrade to pdfbox 2.0 my barcodes are not correctly detected anymore.
I noticed the cause was the result of the page to image rendering implemented in pdfbox 2.0.
The quality of the image is really poor compared to pdfbox 1.8.
See the attached image (comparison.png):
On the left you have the image generated with pdfbox 2.0.13
On the right you have the image generated with pdfbox 1.8.16
We can clearly see the difference.
Both images were generated using the same resolution (200 dpi here):
For 2.0.13:
BufferedImage image = pdfRenderer.renderImageWithDPI(0, 200, ImageType.BINARY);
For 1.8.16:
PDPage page = (PDPage) pdfDocument.getDocumentCatalog().getAllPages().get(0); BufferedImage image = page.convertToImage(BufferedImage.TYPE_BYTE_BINARY, 200);
Buffered images were both written to files using:
ImageIO.write(image, "png", file);
I've attached the pdf file (barcode-128.pdf) and the generated images (barcode-image-2.0.13.png and barcode-image.1.8.16.png)