Some test text!
iOS / Guides / Coordinates
PDFViewCtrl
allows you to convert from one coordinate system to another with ease.
PTPDFViewCtrl* view = [[PTPDFViewCtrl alloc] init];
PTPDFDoc* doc = [[PTPDFDoc alloc] initWithFilepath:filename];
[view SetDoc:doc];
int page = 1;
double x = 0, y = 0;
// Converts a point in a page space to a point in screen space.
PTPDFPoint* screenpt = [view ConvPagePtToScreenPt: [[PTPDFPoint alloc] initWithPx: x py: y] page_num: page];
// Converts a point in screen space to a point in a page space.
PTPDFPoint* pagept = [view ConvScreenPtToPagePt: [[PTPDFPoint alloc] initWithPx: x py: y] page_num: page];
PDF documents have their own coordinate system, which is different from the screen coordinate system of the viewer. For instance, when asking for the position of an annotation element in a PDF document using the Apryse API, the position is given in PDF page coordinates instead of screen coordinates.
Here is an example of a screen capture and table of PDF page coordinates, screen coordinates, and scrolling coordinates
Coordinates | x1 | y1 | x2 | y2 |
---|---|---|---|---|
PDF page coordinates | 62.8 | 165.3 | 538.4 | 415.5 |
Screen coordinates | 62.0 | 1368.6 | 1023.9 | 862.5 |
Scrolling coordinates | 5063.0 | 1368.6 | 6024.9 | 862.5 |
In a PDF document, the location origin (0, 0) is at the bottom left corner of the PDF page. The x axis is positive horizontally to the right and y axis is positive vertically upward. A page location point represents a point in page coordinates. Page points by default is 1⁄72 inch. So an 8.5 x 11 inch page would be 612 x 792 points.
A PDF page can have a rotation associated with it. In this case, the location origin (0, 0) may no longer correspond to the bottom left corner of the page.
For example, here is the page above rotated 90 degrees clockwise. Notice how the location origin (0, 0) is now at the top left corner of the viewport.
In the PDFViewCtrl
class, the location points of the viewer are measured in screen coordinates. Location origin (0, 0) is at the top left corner of the viewport. The x axis is positive horizontally to the right and the y axis is positive vertically downward. A screen location point represents a point in screen coordinates.
Since screen coordinates align to the viewer, if PDFViewCtrl
zooms in, then an element's screen coordinates may change.
For example, here are two screen captures of the same annotation element before and after zooming in, and a table showing how its screen coordinates change.
left (x1) | bottom (y1) | right (x2) | top (y2) | |
---|---|---|---|---|
Before zoom in | 215.8 | 1148.8 | 805.8 | 734.6 |
After zoom in | 2.4 | 1130.0 | 986.8 | 638.8 |
With PDFViewCtrl
, users can flip pages horizontally or vertically. For scrolling coordinates, the location origin (0, 0) is located at the top left corner of the viewer in page 1. The x axis is positive horizontally to the right and the y axis is positive vertically downward.
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales