Some test text!

keyboard_arrow_down

Get started

Download PDFTron SDK
play_arrow

Quick start - view a document

Integrate with NuGetIntegrate manuallyRun samplesAdd license keyUpdate to latest version
keyboard_arrow_down

Xamarin.Forms

keyboard_arrow_down

Fundamentals

keyboard_arrow_down

FAQ

System requirementsPDFTron full vs. standardReduce size of APK
keyboard_arrow_down

Document Viewer

keyboard_arrow_down

Document Viewer components

keyboard_arrow_down

Annotation and collaboration

OverviewToolManager setupRead only mode
play_arrow

Disable annotation creation and editing

play_arrow

Default annotation properties

play_arrow

Change tool mode

play_arrow

Events

play_arrow

Override annotation handling

Show and hide existing annotationsRealtime collaboration
keyboard_arrow_down

Advanced customization

play_arrow

Add a custom view to a page

Create a custom toolPage coloring modePage fit modePage layout modeScrolling direction
keyboard_arrow_down

Conversion

keyboard_arrow_down

Parsing and extraction

keyboard_arrow_down

Digital signatures

keyboard_arrow_down

Search

keyboard_arrow_down

Advanced topics

PrintUnderstand coordinatesGenerate page thumbnails
keyboard_arrow_down

Troubleshooting

keyboard_arrow_down

Reference

keyboard_arrow_down

PDF Processing API

What is PDFNet?Opening a documentSerializing (saving) a documentWorking with pagesWorking with Page ContentWorking with BookmarksWorking with Interactive Forms (AcroForms)PDF SecurityLow-level PDF APIError handling
Understand coordinateskeyboard_arrow_down

Understand coordinates

In this document
chevron_rightPDF page coordinates
chevron_rightScreen coordinates
chevron_rightScrolling coordinates
chevron_rightConverting between different coordinates
This tutorial only applies to Xamarin.Android.

When dealing with locations in PDFViewCtrl it is important to understand what coordinate space they are located in. For example when you get (x, y) value from MotionEvent, the location is relative to the screen, not PDF page.

PDF document has its own coordinate system, which differs from Android's view coordinate system. When you ask for the position of an annotation in a PDF document using the PDFTron API, the position is given in PDF page coordinates instead of Android screen coordinates. To illustrate this, here is a screen capture of an annotation and a table of its coordinates as PDF page coordinates, screen coordinates, and scrolling coordinates:

Coordinatesx1y1x2y2
PDF page coordinates62.8165.3538.4415.5
Screen coordinates62.01368.61023.9862.5
Scrolling coordinates5063.01368.66024.9862.5

linkPDF page coordinates

In a PDF document, the location (0, 0) is at the bottom left corner of the PDF page. The x axis extends horizontally to the right and y axis extends vertically upward. A page point represents a point in page coordinates.

A PDF page may have a rotation associated with it. In this case, the coordinate (0, 0) may no longer correspond to the bottom left corner of the page.

For example, here is the same page shown as above, but rotated 90 degrees clockwise. Notice how the coordinate (0, 0) is now at the top left corner of the viewport.

linkScreen coordinates

In Android views and in the PDFViewCtrl class, the locations of a view are measured in screen coordinates. Point (0, 0) is at the top left corner of the view. The x axis extends horizontally to the right and the y axis extends vertically downward. A screen point represents a point in screen coordinates.

Since screen coordinates measure Android views, if PDFViewCtrl zooms in, the annotation's screen coordinates may change.

For example, here are two screen captures of the same annotation before and after zooming in, and a table showing how its screen coordinates change:

left (x1)bottom (y1)right (x2)top (y2)
Before zoom in215.81148.8805.8734.6
After zoom in2.41130.0986.8638.8

linkScrolling coordinates

In PDFViewCtrl, users can flip pages horizontally or vertically. In scrolling coordinates, the point (0, 0) is located at the top left corner of the view in page 1. The x axis extends horizontally to the right and the y axis extends vertically downward.

linkConverting between different coordinates

PDFViewCtrl allows you to convert from one coordinate system to another with ease:

MethodDescription
ConvPagePtToHorizontalScrollingPtConverts a point from page space to scrolling space.
ConvPagePtToScreenPtConverts a point from page space to screen space.
ConvScreenPtToPagePtConverts a point from screen space to page space.