Some test text!

Getting started

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


Document lockingSaving PDF documentsUnderstanding coordinates


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


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


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


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


Deleting annotationsAnnotation styleShow/hide annotations

UI components

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


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


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

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 color modeskeyboard_arrow_down

Night mode and custom color mode

In this document
chevron_rightSetting day mode, night mode and inverted color mode
chevron_rightSetting custom color mode by gradient map image

PDFViewCtrl supports day mode, night mode, inverted color mode, and custom color mode. In day mode, documents are displayed in their original color. In night mode, colors are adjusted to improve reading at night. In inverted color mode, all colors are inverted. In custom color mode, you can set customized background color and text color to PDFViewCtrl.

Color modes from left to right: day mode, inverted color mode, night mode, custom color mode.

linkSetting day mode, night mode and inverted color mode

To set the color mode:

  1. Find the constant value of the color mode
Color modeConstant value
Day modePDFRasterizer.e_postprocess_none
Night modePDFRasterizer.e_postprocess_night_mode
Inverted color modePDFRasterizer.e_postprocess_invert
Custom color modePDFRasterizer.e_postprocess_gradient_map
  1. To set the color mode, call pdfViewCtrl.setColorPostProcessMode(int):

    For example, set PDFViewCtrl to night mode:


where `pdfViewCtrl` is an instance of `PDFViewCtrl`.
  1. For the best visual results, set PDFViewCtrl client area background color. You can set the client area background color by calling pdfViewCtrl.setClientBackgroundColor(int, int, int, boolean).

    For example, set the client area color to black for night mode:

  2. If you are using PDFRasterizer.e_postprocess_gradient_map, call PDFViewCtrl.setColorPostProcessColors(int, int) to set the white and black points. For example, set white point to dark gray and black points to red.

  3. Update PDFViewCtrl to redraw the contents:


The example below shows all of this functionality being used to set the custom color mode with a dark gray background and red text color.


linkSetting custom color mode by gradient map image

Alternatively, you can also set custom color mode by adding a gradient map image as follows:

  1. Add a gradient map .png image to your project res/raw folder.

    For example, add the following image to res/raw folder and name it custom_mode_filter.png:

    To learn more about res/raw resource directory, see Providing Resources
  2. Set the gradient image to a new MappedFile:

  3. Set the mappedFile created above to PDFViewCtrl by calling PDFViewCtrl.setColorPostProcessMapFile(Filter).


    Where pdfViewCtrl is an instance of PDFViewCtrl.

  4. Set the color process mode PDFRasterizer.e_postprocess_gradient_map to pdfViewCtrl by calling pdfViewCtrl.setColorPostProcessMode(int). Then update pdfViewCtrl: