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

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
Out of memory when rotating device multiple timeskeyboard_arrow_down

Out of memory when rotating device multiple times

In this document
chevron_rightOption 1: Overriding onDestroy() in your activity
chevron_rightOption 2: Configuring your activity to handle configuration changes.

Question:

We are experiencing a lot of out of memory errors when rotating the device multiple times. Since the Activity is destroyed while rotating, we get a new (quite heavy) PDFViewCtrl every time we rotate the device.

When you rotate the device, the activity is recreated, and the current state of PDFViewCtrl is not being finalized correctly. For example, when rotating a device, Android called onCreate(), your activity therefore instantiates a new PDFViewCtrl. The following options could help you get rid of this problem.

linkOption 1: Overriding onDestroy() in your activity

When overriding onDestroy(), call PDFViewCtrl.destroy():



where mPdfCtrl is an instance of PDFViewCtrl.

linkOption 2: Configuring your activity to handle configuration changes.

Another way to remedy this is configuring your activity to handle configuration changes. This way the control will not be recreated and it will be resized accordingly.

  1. In your app AndroidManifest.xml file, add android:configChanges to your activity tag.

    ...
      <activity
        ...
        android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
        >
        ...
      </activity>
    ...
  2. Override onConfigurationChanged() in your activity, and call PDFViewCtrl.onConfigurationChanged(Configuration):



where mPdfCtrl is an instance of PDFViewCtrl.