Support
unread,Jun 29, 2009, 4:44:33 PM6/29/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to PDFTron PDFNet SDK
Q: I have a PDF file that the user rotated after editing. When I open
it with Acrobat Reader the annotations are in the right place but when
I am trying to extract those annotations box, the rectangle has the
old coordinates without any rotation applied to them.
Rect box = annot.getRect();
int rot = page.getRotation();
...
How can I apply the given rotation to the coordinates of the
annotations?
----------
A: Annotation rectangle is represented in PDF user coordinates. To
obtain the positioning information relative to PDF page coordinates
(i.e. taking into account the effects to page rotation and cropping)
you can transform annotation rectangle using 'page.GetDefaultMatrix
()'. For example:
// In C#
Rect box = annot.GetRect();
Matrix2D m = page.GetDefaultMatrix();
double x1=box.x1, y1=box.y1;
m.Mult(ref x1, ref y1);
double x2=box.x2, y2=box.y2;
m.Mult(ref x2, ref y2);
[x1, y1, x2, y2] is are annotation coordinates on a rotated and
cropped page.