Some test text!

keyboard_arrow_down

Get started

Download PDFTron SDKIntegrate with GradleIntegrate manuallyRun samplesAdd PDFTron license keyQuick start - view a documentProGuardUpdate to latest versionTroubleshooting
keyboard_arrow_down

Document Viewer

keyboard_arrow_down

Document Viewer components

PDFViewCtrlReflowFloating context menuCustomize floating context menuAnnotation toolbarAnnotation style editorCustomize annotation style editorPage sliderAnnotation listDocument outlineUser bookmark listList containerThumbnail browserAdd pages dialogRotate pages dialogView mode dialogCrop pages dialog
keyboard_arrow_down

Annotation and collaboration

OverviewToolManager setupRead only modeDisable annotation creation/editingDefault annotation propertiesAnnotation propertiesEventsOverride annotation handlingShow and hide existing annotationsUndo and redoRealtime collaboration
keyboard_arrow_down

Advanced customization

Add a custom view to a pageCreate a custom toolPage coloring modePage fit modePage layout mode
keyboard_arrow_down

Conversion

Convert documents to PDFConvert HTML to PDF
keyboard_arrow_down

Search

Text search
keyboard_arrow_down

Other Frameworks

keyboard_arrow_down

Advanced topics

Understand coordinatesDocument savingDocument lockingGenerate page thumbnailsTool class hierarchy
keyboard_arrow_down

FAQ

System RequirementsRun project in Android StudioRun project with source codePDFTron full vs. standardLocalizationIcon cheat sheetReduce size of APKEnable multidexOut of memory when rotating device multiple timesReduce memory consumptionDetachCurrentThread warning
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
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.