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

OverviewShow a document in an ActivityShow a document in a FragmentViewer configurationDay and Night themesOpen from online URL
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

ToolManager 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

XamarinReact Native
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
Page coloring modekeyboard_arrow_down

Page coloring 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.



Result:

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:

    
    
    
    

Result: