Some test text!

keyboard_arrow_down

Get started

Quick start - view a documentDownload PDFTron SDKIntegrate with GradleIntegrate manuallyRun samplesAdd license keyUpdate to latest versionTroubleshooting
keyboard_arrow_down

FAQ

System requirementsDocument lockingDocument savingRun project in Android StudioRun project with source codePDFTron full vs. standardReduce size of APK
keyboard_arrow_down

Document Viewer

keyboard_arrow_down

Document Viewer components

OverviewPDFViewCtrlReflowQuick menuCustomize quick menuAnnotation toolbarAnnotation style editorCustomize annotation style editorPage sliderList containerAnnotation listDocument outlineUser bookmark listThumbnail browserAdd pages dialogCrop pages dialogRotate pages dialogView mode dialog
keyboard_arrow_down

Annotation and collaboration

OverviewRead only modeDisable annotation creation and editingDefault annotation propertiesChange tool modeEventsOverride annotation handlingShow and hide existing annotationsUndo and redoRealtime collaboration
keyboard_arrow_down

Advanced customization

OverviewAdd a custom view to a pageCreate a custom toolPage coloring modePage fit modePage layout modeScrolling directionRight-to-left support
keyboard_arrow_down

Conversion

keyboard_arrow_down

Parsing and extraction

keyboard_arrow_down

Digital signatures

keyboard_arrow_down

Search

keyboard_arrow_down

Advanced topics

keyboard_arrow_down

Other frameworks

XamarinReact Native
keyboard_arrow_down

Troubleshooting

keyboard_arrow_down

Reference

ProGuardLocalizationIcon cheat sheet
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
Add a custom view to a pagekeyboard_arrow_down

Add a custom view to a page

In this document
chevron_rightShow CustomRelativeLayout
chevron_rightAdd custom layout programmatically
chevron_rightXML attributes

CustomRelativeLayout is a RelativeLayout that can be nested under PDFViewCtrl with a given page position and page number. All child views of CustomRelativeLayout are displayed on top of PDFViewCtrl. When PDFViewCtrl is scrolling or zooming, CustomRelativeLayout will adjust position and size automatically according to the app:zoomWithParent attribute.

The position of CustomRelativeLayout is calculated in PDF page coordinates. In page coordinate, the origin 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. For more information, see: understanding coordinates

linkShow CustomRelativeLayout

You can add CustomRelativeLayout as a child view of PDFViewCtrl in your XML layout resource file:

<com.pdftron.pdf.PDFViewCtrl
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/pdfviewctrl"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical|horizontal" >
    <com.pdftron.pdf.tools.CustomRelativeLayout
        android:layout_width="50dp"
        android:layout_height="50dp"
        app:posX="50"
        app:posY="150"
        app:pageNum="3"
        app:zoomWithParent="true">
        <!--Child views under CustomRelativeLayout-->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Custom Layout Text View"
            android:textSize="24dp"
            android:elevation="2dp"/>
        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/light_gray" />
    </com.pdftron.pdf.tools.CustomRelativeLayout>
</com.pdftron.pdf.PDFViewCtrl>
If you delete the page defined in CustomRelativeLayout, the CustomRelativeLayoutwill not be removed from PDFViewCtrl. Please remember to remove CustomRelativeLayout manually.

linkAdd custom layout programmatically

Alternatively, you can also add CustomRelativeLayout programmatically. Here is an example where the CustomRelativeLayout is inflated and added directly to PDFViewCtrl.

  1. Define an XML layout resource file containing a CustomRelativeLayout. For example, our layout file R.layout.custom_layout_textview shown below contains a CustomRelativeLayout with two child views:

    <com.pdftron.pdf.tools.CustomRelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="50dp"
        android:layout_height="50dp"
        app:posX="50"
        app:posY="150"
        app:pageNum="3"
        app:zoomWithParent="true">
        <!--Child views under CustomRelativeLayout-->
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Custom Layout Text View"
            android:textSize="24dp"
            android:elevation="2dp"/>
        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/light_gray" />
    </com.pdftron.pdf.tools.CustomRelativeLayout>
  1. Then you can inflate the layout and add it directly to PDFViewCtrl:

If you delete the page defined in CustomRelativeLayout, the CustomRelativeLayoutwill not be removed from PDFViewCtrl. Please remember to remove CustomRelativeLayout manually.

linkXML attributes

CustomRelativeLayout allows child views to be displayed inside PDFViewCtrl. XML attributes for positioning CustomRelativeLayout in PDFViewCtrl are defined in the table below:

AttributeDescription
app:posXSpecifies the x-coordinate in PDF page coordinates.

Default value: 0
app:posYSpecifies the y-coordinate in PDF page coordinates.

Default value: 0
app:pageNumSpecifies the page number of the document that will contain this CustomRelativeLayout.

Default value: 1
app:zoomWithParentSpecifies whether the CustomRelativeLayout will zoom with parent.

Default value: true
android:layout_widthSpecifies the width of the view, it must be a positive integer in PDF page coordinates.
android:layout_heightSpecifies the height of the view, it must be a positive integer in PDF page coordinates.