Some test text!

keyboard_arrow_down

Get started

Download PDFTron SDK
play_arrow

Quick start - view a document

Xamarin.AndroidXamarin.iOSIntegrate with NuGetIntegrate manuallyRun samplesAdd license keyUpdate to latest version
keyboard_arrow_down

Xamarin.Forms

Document viewerBasic viewer
keyboard_arrow_down

Fundamentals

Java binding (Android)Objective-C binding (iOS)Code sharingDocument lockingDocument saving
keyboard_arrow_down

FAQ

System requirementsPDFTron full vs. standardReduce size of APK
keyboard_arrow_down

Document Viewer

play_arrow

Xamarin.Android

OverviewShow a document in an ActivityShow a document in a FragmentViewer configurationToolManager configurationDay and Night themes
play_arrow

Xamarin.iOS

Open from online URL
keyboard_arrow_down

Document Viewer components

Overview
play_arrow

PDFViewCtrl

Xamarin.AndroidXamarin.iOS
play_arrow

Reflow

Xamarin.AndroidXamarin.iOSQuick menuCustomize quick menu
play_arrow

Annotation toolbar

play_arrow

Annotation style editor

Xamarin.AndroidXamarin.iOS
play_arrow

Page slider

play_arrow

List container

play_arrow

Annotation list

play_arrow

Document outline

play_arrow

User bookmark list

play_arrow

Thumbnail browser

Add pages dialogCrop pages dialogRotate pages dialogView mode dialog
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

Xamarin.AndroidXamarin.iOS
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

Xamarin.AndroidXamarin.iOSCreate a custom toolPage coloring modePage fit modePage layout modeScrolling direction
keyboard_arrow_down

Conversion

play_arrow

Convert documents to PDF

Xamarin.AndroidXamarin.iOS
play_arrow

Convert HTML to PDF

keyboard_arrow_down

Parsing and extraction

keyboard_arrow_down

Digital signatures

keyboard_arrow_down

Search

play_arrow

Text search

Xamarin.AndroidXamarin.iOS
keyboard_arrow_down

Advanced topics

keyboard_arrow_down

Troubleshooting

keyboard_arrow_down

Reference

LocalizationIcon 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

PDFViewCtrl

In this document
chevron_rightView documents using PDFViewCtrl
chevron_rightView from resource
chevron_rightView from local device storage
chevron_rightView from content uri
chevron_rightView from HTTP/HTTPS
chevron_rightManaging lifecycle
chevron_rightNext steps
This tutorial only applies to Xamarin.Android.
If you are looking for a quick start on displaying documents in your application, please first take a look at Show a document in an Activity or Show a document in a Fragment as they are easier to setup and ready to launch from any activity or fragment. Continue reading this article if you are looking to embed PDFViewCtrl in your own layout.
Before beginning, make sure the PDFTron library is initialized prior to inflating the layout or calling setContentView in your activity.

PDFViewCtrl is a ViewGroup that can be embedded in any layout. It encapsulates a rich set of functionalities for interactive viewing of PDF documents, including multi-threaded rendering, PDF rendering settings, scrolling, zooming, page navigation, different page viewing modes, coordinates conversion, text selection, text search, etc.

linkView documents using PDFViewCtrl

In this tutorial you will display a PDF file in your activity by using PDFViewCtrl.

  1. In your AndroidManifest.xml, make sure you enable largeHeap in the <application> tag. Also, add a custom theme and set the android:windowSoftInputMode:"adjustPan" attribute in the <activity> tag as follow:

    <application
        ...
        android:name="android.support.multidex.MultiDexApplication"
        android:largeHeap="true">
        
        ...
        
        <activity
            ...
            android:windowSoftInputMode="adjustPan"
            android:theme="@style/CustomAppTheme"/>
    </application>
    If your app is targeting Android SDK version 28 or higher, please also set the android:usesCleartextTraffic="true" attribute in your application tag.
  2. Create a custom theme for your activity in res/values/styles.xml:

    <resources>
    <style name="CustomAppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="colorPrimary">#3F51B5</item>
        <item name="colorPrimaryDark">#303F9F</item>
        <item name="colorAccent">#FF4081</item>
        <!-- Action bar -->
        <item name="actionModeBackground">?attr/colorPrimary</item>
        <item name="windowActionModeOverlay">true</item>
    </style>
    </resources>
    PDFViewCtrl uses the AppCompat theme for material colors. Make sure that the value of android:theme in your <activity> tag also extends the AppCompat theme.
  3. Now, add PDFViewCtrl to your activity's XML layout. For example:

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <pdftron.pdf.PDFViewCtrl
            android:id="@+id/pdfviewctrl"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical|horizontal"/>
    
    </FrameLayout>
  4. In your activity, get a reference to PDFViewCtrl after inflating the layout and call AppUtils.SetupPDFViewCtrl.

  5. Next, choose a document to display by using the following options:

    linkView from resource

    Add a sample PDF to src/main/res/raw folder, then call:

    linkView from local device storage

    To access device storage, add the following permissions to the AndroidManifest.xml file in the <manifest> tag (outside of the <application> tag):

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    Then call:

    linkView from content uri

    linkView from HTTP/HTTPS

    To access via the internet, add the following permissions to the AndroidManifest.xml file in the <manifest> tag (outside of the <application> tag):

    <uses-permission android:name="android.permission.INTERNET"/>

    Then call:

linkManaging lifecycle

It is extremely important that you follow the Android activity/fragment lifecycle and clean up PDFViewCtrl and PDFDoc properly. Make sure you have the following in lifecycle callbacks:

linkNext steps