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

Rotated pages produce matrix value like -0.999999999999999 instead of -1

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.13
    • Fix Version/s: 2.0.14, 3.0.0 PDFBox
    • Component/s: Rendering
    • Labels:
      None

      Description

      I was wondering why I got AffineTransform objects like

      AffineTransform[[-4.371139E-8, 0.999999999999999, 7.96E-13], [0.999999999999999, 4.371139E-8, -3.4619420881E-5]]
      

      which makes debugging difficult, instead of

      AffineTransform[[0.0, 1.0, -0.0], [1.0, 0.0, -0.0]]
      

      The cause is this code line in PDFRenderer:

      graphics.rotate((float) Math.toRadians(rotationAngle));
      

      Solution: removing the cast produces a nice AffineTransform object:

      graphics.rotate(Math.toRadians(rotationAngle));
      

      However... this resulted in rendering bugs in several files (gs-bugzilla690022-reduced-rotations.pdf, gs-bugzilla690022-reduced-rotations-cropbox.pdf, PDFJS-5811-2-p4_reduced-rotations.pdf). Researching this found that getScalingFactorX() and getScalingFactorY() return negative values which they didn't before. Using Math.abs() solves this problem and now two files are slightly better (lines no longer very slightly diagonal): PDFBOX-2376-466070.pdf page 24 and PDFBOX-4399-046615_p9_OCG-NoRotate-Annotations.pdf .

        Attachments

          Activity

            People

            • Assignee:
              tilman Tilman Hausherr
              Reporter:
              tilman Tilman Hausherr
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: