Issues calculating viewer coordinates for a rotated PDF page. #1725
Unanswered
sameer-roofr
asked this question in
Q&A
Replies: 1 comment
-
I was struggling with the same thing, and I was able to come up with this demo that should work. I also realized the hard way that despite page rotation, the dimensions and orientation don't change. Define the coordinates (as xCoord and yCoord below) from the perspective that 0,0 is always in the upper left visually, regardless of a page's rotation. For 0, 90, 180 and 270 degree rotation, the image should show up at the same coordinates visually at any of these rotations.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a service that accepts annotations with coordinates and dimensions and places them on a PDF page. Standard functions like page.drawRectangle and pdfPage.drawText work correctly with some adjustments. However, when working with a rotated PDF page, I am facing challenges.
Specifically, the PDF coordinates and viewer coordinates differ, which is expected. To address this, I wrote a wrapper function to convert PDF coordinates to viewer coordinates. However, I noticed that when a PDF page is rotated, the library still returns the original (unrotated) dimensions via page.getSize(). For example, if a rotated page appears as 1000x800 in the viewer, page.getSize() still returns 800x1000 (its original dimensions at 0 degrees).
Is there a way to get the viewer coordinates or the correctly rotated dimensions for a PDF page instead of the original unrotated values?
tldr; I want to know how to get viewer coordinates, origin (0,0) is top-left, for rotated PDF pages.
Beta Was this translation helpful? Give feedback.
All reactions