Some test text!

Getting started

keyboard_arrow_down
Running samplesTry demo in your projectDownloading PDFTronIntegrating PDFTron via GradleManually integrating PDFTronUpgradingAdding PDFTron license keyUsing ProGuardTroubleshooting integration

Fundamentals

keyboard_arrow_down
Document lockingSaving PDF documentsUnderstanding coordinates

Basics

keyboard_arrow_down
Using an ActivityUsing a FragmentUsing PDFViewCtrlViewer configConverting and viewing other document typesConverting HTML to PDF

Viewer

keyboard_arrow_down
PDFViewCtrl color modesPDFViewCtrl page view modePDFViewCtrl page presentation modeGenerating thumbnails in PDF

Features

keyboard_arrow_down
Day/Night themesUndo and redoText searchAnnotation syncingRotating PDF pagesPDFViewCtrl read onlyUsing PDFViewCtrl with minimum memory

Tools

keyboard_arrow_down
Tools overviewSetting Up ToolManagerChanging and disabling toolsIntercepting annotation handlingToolManager eventsDefault annotation propertiesTool subclasses

Annotations

keyboard_arrow_down

UI components

keyboard_arrow_down
Quick menuAnnotation toolbarAnnotation style dialogThumbnail sliderAnnotations listOutline listUser bookmarks listBookmarks dialogPage thumbnails dialogAdd page dialogRotate pages dialogView mode dialogCrop page dialogReflow

Advanced

keyboard_arrow_down
Adding a custom view to a PDF pageCustom toolCustomizing quick menuCustomizing annotation style dialog

FAQ

keyboard_arrow_down
Running project in Android StudioSystem RequirementsPDFTron full vs. standardLocalizationIcon cheat sheetRunning sample with sourceReducing size of APKEnable multidexOut of memory when rotating device multiple timesDetachCurrentThread warning

PDF Processing API

keyboard_arrow_down
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
Understanding coordinateskeyboard_arrow_down

Understanding coordinates

In this document
chevron_rightPDF page coordinates (page pt)
chevron_rightScreen coordinates (screen pt)
chevron_rightScrolling coordinates
chevron_rightConverting between different coordinates

PDF documents have their own coordinate system, which differs from Android's 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 (page pt)

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 pt represents a point in page coordinates.

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

For example, here is the same page as above, but rotated 90 degrees clockwise. Notice how the coordinates of the points in the rotated page have all stayed the same in relation to each other, but the coordinate (0, 0) is now at the top left corner of the viewport.

linkScreen coordinates (screen pt)

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 pt 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
convPagePtToHorizontalScrollingPt(double, double, int)Converts a point from page space to scrolling space.
convPagePtToScreenPt(double, double, int)Converts a point from page space to screen space.
convScreenPtToPagePt(double, double, int)Converts a point from screen space to page space.