Olivier M created PDFBOX-4391:
---------------------------------
Summary: Page to image rendering in pdfbox 2.0: Poor quality
compared to 1.8
Key: PDFBOX-4391
URL: https://issues.apache.org/jira/browse/PDFBOX-4391
Project: PDFBox
Issue Type: Bug
Components: Rendering
Affects Versions: 2.0.13
Environment: Windows 10
JDK 1.8.0_181
Reporter: Olivier M
Attachments: barcode-128.pdf, barcode-image-1.8.16.png,
barcode-image-2.0.13.png, comparison.png
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:
{code:java}
BufferedImage image = pdfRenderer.renderImageWithDPI(0, 200,
ImageType.BINARY);{code}
For 1.8.16:
{code:java}
PDPage page = (PDPage) pdfDocument.getDocumentCatalog().getAllPages().get(0);
BufferedImage image = page.convertToImage(BufferedImage.TYPE_BYTE_BINARY,
200);{code}
Buffered images were both written to files using:
{code:java}
ImageIO.write(image, "png", file); {code}
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)
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]