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

PDFRenderer.renderImageWithDPI DPI parameter ignored in 2.0.20

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.0.20
    • None
    • Rendering
    • None
    • x64 windows. several 64-bit Java 8 JREs
    • Important

    Description

      org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI method no longer correctly renders pixels in a raster graphic PDF at the resolution requested.

      PDFRenderer pdfRenderer = new PDFRenderer(PDDocument.load(new File("sample_bilevel_raster.pdf")));
      BufferedImage bi = pdfRenderer.renderImageWithDPI(0, 300, ImageType.RGB);
      javax.imageio.ImageIO.write(bim, "PNG", new File("my png filename));

      I tested this with all Pdfbox 2 releases (2.0.0 - 2.0.20) and found this bug only affecting 2.0.20. 2.0.0-2.0.19 produced correct output.

      it appears v20 renders onto a destination image of the correct size but the source image is set at 72 DPI causing the destination pixels to be extrapolated gray-scale.

      This is reproducible with any bi-level raster PDF I used. See attached input and output files.

       

       

      Attachments

        1. sample_bilevel_raster-21.png
          709 kB
          Tilman Hausherr
        2. 2.0.8.png
          707 kB
          chris laws
        3. 2.0.16.png
          707 kB
          chris laws
        4. 2.0.18.png
          707 kB
          chris laws
        5. 2.0.17.png
          707 kB
          chris laws
        6. 2.0.12.png
          707 kB
          chris laws
        7. 2.0.15.png
          707 kB
          chris laws
        8. 2.0.10.png
          707 kB
          chris laws
        9. 2.0.14.png
          707 kB
          chris laws
        10. 2.0.13.png
          707 kB
          chris laws
        11. 2.0.11.png
          707 kB
          chris laws
        12. 2.0.20.png
          2.13 MB
          chris laws
        13. 2.0.6.png
          707 kB
          chris laws
        14. 2.0.7.png
          707 kB
          chris laws
        15. 2.0.9.png
          707 kB
          chris laws
        16. 2.0.4.png
          707 kB
          chris laws
        17. 2.0.1.png
          707 kB
          chris laws
        18. 2.0.19.png
          707 kB
          chris laws
        19. 2.0.0.png
          707 kB
          chris laws
        20. 2.0.5.png
          707 kB
          chris laws
        21. 2.0.2.png
          707 kB
          chris laws
        22. 2.0.3.png
          707 kB
          chris laws
        23. sample_bilevel_raster.pdf
          51 kB
          chris laws

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            LAWSCACTUS chris laws
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment