Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4391

Page to image rendering in pdfbox 2.0: Poor quality compared to 1.8

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.13
    • 2.0.14
    • Rendering
    • Windows 10
      JDK 1.8.0_181
      JDK 1.8.0_192

    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)

       

       

       

       

      Attachments

        1. barcode-128-BW-antialiasing-off.png
          10 kB
          Tilman Hausherr
        2. comparison.png
          23 kB
          Olivier Masseau
        3. barcode-image-2.0.13.png
          10 kB
          Olivier Masseau
        4. barcode-image-1.8.16.png
          10 kB
          Olivier Masseau
        5. barcode-128.pdf
          15 kB
          Olivier Masseau

        Activity

          People

            tilman Tilman Hausherr
            maol Olivier Masseau
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: