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

Image clipping area rounding error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.11
    • 2.0.12, 3.0.0 PDFBox
    • Rendering
    • None
    • Patch

    Description

      Creating images with PDFBox and merging them together when you have two pages that connect will create a white line between the images.

      We have looked into the issue and tried to fix it and found that the clipping area is a bit to tight so the images will not be rendered correctly. My guess is that this is due to a rounding error when using floats. 

      Most of the graphics functions in java use double precision and PDFBox uses floats so when using layer upon layer of bounding boxes intersecting the clipping area it might get skewed to a bad bounding box.

      I've added a patch to this issue with the code we use as a workaround today. It's by no means the final solution to the problem but it resolves the white line issue.

      To be sure that you get the error when generating the images use the following command

      ```
      java -jar pdfbox-app-3.0.0-SNAPSHOT.jar PDFToImage -dpi 150 -quality 0.95 -format jpg page-1.pdf
      ```

      We run java 8 on our machines.

      Attachments

        1. page-1.pdf
          430 kB
          Daniel Persson
        2. page-2.pdf
          600 kB
          Daniel Persson
        3. patch.diff
          1 kB
          Daniel Persson
        4. test.jpg
          1.01 MB
          Daniel Persson
        5. patch2.diff
          0.8 kB
          Daniel Persson

        Issue Links

          Activity

            People

              tilman Tilman Hausherr
              kalaspuffar Daniel Persson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: