Some test text!
PDFViewCtrl allows you to convert from one coordinate system to another with ease.
std::auto_ptr<PDF::PDFViewCtrl> view; view = std::auto_ptr<pdftron::PDF::PDFViewCtrl>(new pdftron::PDF::PDFViewCtrl(parent_hwnd, hinstance)); std::auto_ptr<PDF::PDFDoc> doc(new PDF::PDFDoc(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. view->ConvPagePtToScreenPt(x, y, page); // Converts a point in screen space to a point in a page space. view->ConvScreenPtToPagePt(x, y, 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 PDFTron 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
|PDF page coordinates||62.8||165.3||538.4||415.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.
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|
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.
Get the answers you need: Support
Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.
Select a platform to get started with your free trial.
Unlimited usage. No email address required.