Skip to content

Customize UI via Configuration File

This section explains how to customize built-in UI with UI Extensions on Android using uiextensions_config.json. You can control UI scope and behavior without changing application code, for example:

  • Enable or disable feature modules (modules)
  • Permission switches (permissions)
  • UI behavior and style (uiSettings: page mode, link highlight, default annotation properties, etc.)

Rebuild and run the app after changing the configuration.

Configuration File Location

In the SDK sample project:

  • samples/complete_pdf_viewer/app/src/main/res/raw/uiextensions_config.json

Place the file the same way in your own project.

JSON File Overview

UI Extensions configuration can come from a JSON file or a code-built config object. JSON is recommended for readability and diff review.

Sample Configuration (uiextensions_config.json)

The complete sample configuration below is a template—adjust a few keys to validate customization quickly.

[uiextensions_config.json (full sample)]
json
{
  "modules": {
    "readingbookmark": true,
    "outline": true,
    "annotations": {
      "highlight": true,
      "underline": true,
      "squiggly": true,
      "strikeout": true,
      "insert": true,
      "replace": true,
      "line": true,
      "rectangle": true,
      "oval": true,
      "arrow": true,
      "pencil": true,
      "eraser": true,
      "typewriter": true,
      "textbox": true,
      "callout": true,
      "note": true,
      "stamp": true,
      "polygon": true,
      "cloud": true,
      "polyline": true,
      "measure": true,
      "image": true,
      "audio": true,
      "video": true
    },
    "thumbnail": true,
    "attachment": true,
    "signature": true,
    "search": true,
    "pagenavigation": true,
    "form": true
  },
  "permissions": {
    "runJavaScript": true,
    "enableLink": true
  },
  "uiSettings": {
    "pageMode": "Single",
    "continuous": false,
    "zoomMode": "FitWidth",
    "colorMode": "Normal",
    "mapForegroundColor": "#5d5b71",
    "mapBackgroundColor": "#00001b",
    "enableFormNavigationBar": true,
    "highlightForm": true,
    "highlightFormColor": "#200066cc",
    "highlightLink": true,
    "highlightLinkColor": "#16007fff",
    "annotations": {
      "continuouslyAdd": true,
      "highlight": {
        "color": "#ffff00",
        "opacity": 1.0
      },
      "areaHighlight": {
        "color": "#ffff00",
        "opacity": 1.0
      },
      "underline": {
        "color": "#66cc33",
        "opacity": 1.0
      },
      "squiggly": {
        "color": "#993399",
        "opacity": 1.0
      },
      "strikeout": {
        "color": "#ff0000",
        "opacity": 1.0
      },
      "insert": {
        "color": "#993399",
        "opacity": 1.0
      },
      "replace": {
        "color": "#0000ff",
        "opacity": 1.0
      },
      "line": {
        "color": "#ff0000",
        "opacity": 1.0,
        "thickness": 2
      },
      "rectangle": {
        "color": "#ff0000",
        "opacity": 1.0,
        "thickness": 2,
        "fillColor": null
      },
      "oval": {
        "color": "#ff0000",
        "opacity": 1.0,
        "thickness": 2,
        "fillColor": null
      },
      "arrow": {
        "color": "#ff0000",
        "opacity": 1.0,
        "thickness": 2
      },
      "pencil": {
        "color": "#ff0000",
        "opacity": 1.0,
        "thickness": 2,
        "stylusOnly": false
      },
      "polygon": {
        "color": "#ff0000",
        "opacity": 1.0,
        "thickness": 2,
        "fillColor": null
      },
      "cloud": {
        "color": "#ff0000",
        "opacity": 1.0,
        "thickness": 2,
        "fillColor": null
      },
      "polyline": {
        "color": "#ff0000",
        "opacity": 1.0,
        "thickness": 2
      },
      "typewriter": {
        "textColor": "#0000ff",
        "opacity": 1.0,
        "textFace": "Courier",
        "textSize": 18
      },
      "textbox": {
        "color": "#ff0000",
        "textColor": "#0000ff",
        "opacity": 1.0,
        "textFace": "Courier",
        "textSize": 18
      },
      "callout": {
        "color": "#ff0000",
        "textColor": "#0000ff",
        "opacity": 1.0,
        "textFace": "Courier",
        "textSize": 18
      },
      "note": {
        "color": "#ff0000",
        "opacity": 1.0,
        "icon": "Comment"
      },
      "attachment": {
        "color": "#ff0000",
        "opacity": 1.0,
        "icon": "PushPin"
      },
      "image": {
        "rotation": 0,
        "opacity": 1.0
      },
      "measure": {
        "color": "#ff0000",
        "opacity": 1.0,
        "thickness": 2,
        "scaleFromUnit": "inch",
        "scaleToUnit": "inch",
        "scaleFromValue": 1.0,
        "scaleToValue": 1.0
      }
    },
    "form": {
      "textField": {
        "textColor": "#000000",
        "textFace": "Courier",
        "textSize": 0
      },
      "checkBox": {
        "textColor": "#000000"
      },
      "radioButton": {
        "textColor": "#000000"
      },
      "comboBox": {
        "textColor": "#000000",
        "textFace": "Courier",
        "textSize": 0,
        "customText": false
      },
      "listBox": {
        "textColor": "#000000",
        "textFace": "Courier",
        "textSize": 0,
        "multipleSelection": false
      }
    },
    "signature": {
      "color": "#000000",
      "thickness": 8
    }
  }
}

Important

  • Defaults: Omitted keys use SDK defaults. For example, highlight may stay enabled even if "highlight": true is missing or commented out.

  • Attachments vs annotations:

    • Sub-keys under modules.annotations (e.g. highlight, underline) control tools in the annotation UI.
    • Attachment features (panel and attachment annotation entry) are controlled by top-level modules.attachment, not by modules.annotations sub-keys.
    • To hide all annotation-related entries in Comment, disable both modules.annotations and modules.attachment.

    Example (relationship only):

    json
    {
      "modules": {
        "annotations": false,
        "attachment": false
      }
    }

JSON Configuration Reference

The JSON file has three main sections: modules, permissions, and uiSettings (UI element properties).

Module Configuration

Module values are boolean: true enables, false disables. Default is true.

ModuleDescription
readingbookmarkUser-defined reading bookmarks
outlinePDF document outline (bookmarks)
annotations (highlight, underline, squiggly, strikeout, insert, replace, line, rectangle, oval, arrow, pencil, eraser, typewriter, textbox, callout, note, stamp, polygon, cloud, polyline, measure, image, audio, video)Annotation tools
thumbnailThumbnails and page management
attachmentDocument attachments and attachment annotations
SignatureDigital and handwriting signatures
fillSignFill flat (non-interactive) forms with text and symbols
searchText search
navigationPage navigation
formForm filling and data import/export
selectionText selection
encryptionPDF encryption
multipleSelectionMulti-select annotations

Permission Configuration

Permission values are boolean. runJavaScript and copyText default to true; disableLink defaults to false.

PermissionDescription
runJavaScriptAllow JavaScript execution
copyTextAllow text copy
disableLinkDisable hyperlinks

Basic UI Settings

ParameterTypeDescription
Page display
pageModeStringPage display mode
Values:Single / Facing / CoverLeft / CoverMiddle / CoverRight / Reflow
Default:Single
Note: Reflow is not supported for dynamic XFA
continuousBoolContinuous single-page display
Values:true / false
Default:false
Note: Not used in Reflow mode
zoomModeStringPage zoom mode
Values:FitWidth / FitPage
Default:FitWidth
Color and display
colorModeStringPage color mode
Values:Normal / Night / Map
Default:Normal
Note: Night is a special Map mode
mapForegroundColorRGBForeground color (Map only)
Default:#5d5b71
mapBackgroundColorRGBBackground color (Map only)
Default:#00001b
Form and links
disableFormNavigationBarBoolDisable form navigation bar
Values:true / false
Default:false
highlightFormBoolHighlight form fields
Values:true / false
Default:true
highlightFormColorARGBForm highlight color
Default:#200066cc
Note: Includes alpha; not for dynamic XFA
highlightLinkBoolHighlight hyperlinks
Values:true / false
Default:true
highlightLinkColorARGBLink highlight color
Default:#16007fff
Note: Includes alpha

Annotation settings (annotations)

ParameterTypeDescription
General
continuouslyAddBoolContinuously add same annotation type
Values:true / false
Default:true
Text markup annotations
highlight.colorRGBHighlight color
Default:#ffff00
highlight.opacitynumericHighlight opacity
Values:[0.0-1.0]
Default:1.0
areaHighlight.colorRGBArea highlight color
Default:#ffff00
areaHighlight.opacitynumericArea highlight opacity
Values:[0.0-1.0]
Default:1.0
Note: Uses default when area exceeds page
underline.colorRGBUnderlinecolor
Default:#66cc33
underline.opacitynumericUnderlineopacity
Values:[0.0-1.0]
Default:1.0
squiggly.colorRGBSquigglycolor
Default:#993399
squiggly.opacitynumericSquigglyopacity
Values:[0.0-1.0]
Default:1.0
strikeout.colorRGBStrikethroughcolor
Default:#ff0000
strikeout.opacitynumericStrikethroughopacity
Values:[0.0-1.0]
Default:1.0
insert.colorRGBInsert markcolor
Default:#993399
insert.opacitynumericInsert markopacity
Values:[0.0-1.0]
Default:1.0
replace.colorRGBReplace markcolor
Default:#0000ff
replace.opacitynumericReplace markopacity
Values:[0.0-1.0]
Default:1.0
Shape annotations
line.colorRGBLinecolor
Default:#ff0000
line.opacitynumericLineopacity
Values:[0.0-1.0]
Default:1.0
line.thicknessnumericLinewidth
Values:[1-12]
Default:2
rectangle.colorRGBRectanglebordercolor
Default:#ff0000
rectangle.opacitynumericRectangleopacity
Values:[0.0-1.0]
Default:1.0
rectangle.thicknessnumericRectangleborderwidth
Values:[1-12]
Default:2
rectangle.fillColorRGBRectanglefill color
Default:null
oval.colorRGBOvalbordercolor
Default:#ff0000
oval.opacitynumericOvalopacity
Values:[0.0-1.0]
Default:1.0
oval.thicknessnumericOvalborderwidth
Values:[1-12]
Default:2
oval.fillColorRGBOvalfill color
Default:null
arrow.colorRGBArrowcolor
Default:#ff0000
arrow.opacitynumericArrowopacity
Values:[0.0-1.0]
Default:1.0
arrow.thicknessnumericArrowline width
Values:[1-12]
Default:2
pencil.colorRGBPencilcolor
Default:#ff0000
pencil.opacitynumericPencilopacity
Values:[0.0-1.0]
Default:1.0
pencil.thicknessnumericPencilthickness
Values:[1-12]
Default:2
pencil.addHistoricalPointsBoolWhether to add historical points for current frame
Values:true / false
Default:true
polygon.colorRGBPolygonbordercolor
Default:#ff0000
polygon.opacitynumericPolygonopacity
Values:[0.0-1.0]
Default:1.0
polygon.thicknessnumericPolygonborderwidth
Values:[1-12]
Default:2
polygon.fillColorRGBPolygonfill color
Default:null
cloud.colorRGBCloudbordercolor
Default:#ff0000
cloud.opacitynumericCloudopacity
Values:[0.0-1.0]
Default:1.0
cloud.thicknessnumericCloudborderwidth
Values:[1-12]
Default:2
cloud.fillColorRGBCloudfill color
Default:null
polyline.colorRGBPolylinecolor
Default:#ff0000
polyline.opacitynumericPolylineopacity
Values:[0.0-1.0]
Default:1.0
polyline.thicknessnumericPolylinewidth
Values:[1-12]
Default:2
Text annotations
typewriter.textColorRGBTypewritertextcolor
Default:#0000ff
typewriter.opacitynumericTypewriteropacity
Values:[0.0-1.0]
Default:1.0
typewriter.textFaceStringTypewriter font
Values:Courier / Helvetica / Times
Default:Courier
Note:invalid value uses defaultfont
typewriter.textSizeIntegerTypewriter font size
Values:>=1
Default:18
textbox.colorRGBText boxbordercolor
Default:#ff0000
textbox.textColorRGBText boxtextcolor
Default:#0000ff
textbox.opacitynumericText boxopacity
Values:[0.0-1.0]
Default:1.0
textbox.textFaceStringText box font
Values:Courier / Helvetica / Times
Default:Courier
Note:invalid value uses defaultfont
textbox.textSizeIntegerText box font size
Values:>=1
Default:18
callout.colorRGBCalloutbordercolor
Default:#ff0000
callout.textColorRGBCallouttextcolor
Default:#0000ff
callout.opacitynumericCalloutopacity
Values:[0.0-1.0]
Default:1.0
callout.textFaceStringCallout font
Values:Courier / Helvetica / Times
Default:Courier
Note:invalid value uses defaultfont
callout.textSizeIntegerCallout font size
Values:>=1
Default:18
Other annotations
note.colorRGBNotecolor
Default:#ff0000
note.opacitynumericNoteopacity
Values:[0.0-1.0]
Default:1.0
note.iconStringNote icon type
Values:Comment / Key / Note / Help / NewParagraph / Paragraph / Insert
Default:Comment
Note:invalid value uses default icon
attachment.colorRGBAttachmentcolor
Default:#ff0000
attachment.opacitynumericAttachmentopacity
Values:[0.0-1.0]
Default:1.0
attachment.iconStringAttachment icon type
Values:Graph / PushPin / Paperclip / Tag
Default:PushPin
Note:invalid value uses default icon
image.rotationnumericImagerotation
Values:0 / 90 / 180 / 270
Default:0
image.opacitynumericImageopacity
Values:[0.0-1.0]
Default:1.0
image.textSizeIntegerImagetextCallout font size
Values:>=1
Default:12
measure.colorRGBMeasure linecolor
Default:#ff0000
measure.opacitynumericMeasure lineopacity
Values:[0.0-1.0]
Default:1.0
measure.thicknessnumericMeasure linewidth
Values:[1-12]
Default:2
measure.scaleFromUnitStringScale from unit
Values:pt / m / cm / mm / inch / p / ft / yd
Default:inch
Note: Base unit for scale
measure.scaleToUnitStringScale to unit
Values:pt / m / cm / mm / inch / p / ft / yd
Default:inch
Note: Target unit for scale
measure.scaleFromValuenumericScale from value
Default:1.0
Note: Base value for scale
measure.scaleToValuenumericScale to value
Default:1.0
Note: Target value for scale

Form control settings (form)

ParameterTypeDescription
form.textField settings
form.textField.textColorRGBtextcolor
Default:#000000
form.textField.textFaceStringtextfont name
Values:Courier / Helvetica / Times
Default:Courier
Note:If invalid, uses defaultfont
form.textField.textSizeIntegertextfont size
Values:>=0
Default:0
Note:0 means auto-adjust font size
form.checkBox settings
form.checkBox.textColorRGBCheckboxtextcolor
Default:#000000
form.radioButton settings
form.radioButton.textColorRGBRadio buttontextcolor
Default:#000000
form.comboBox settings
form.comboBox.textColorRGBCombo boxtextcolor
Default:#000000
form.comboBox.textFaceStringCombo boxtextfont name
Values:Courier / Helvetica / Times
Default:Courier
Note:If invalid, uses defaultfont
form.comboBox.textSizeIntegerCombo boxtextfont size
Values:>=0
Default:0
Note:0 means auto-adjust font size
form.comboBox.customTextBoolCombo box allow custom text
Values:true / false
Default:false
Note: true allows custom text
form.listBox settings
form.listBox.textColorRGBList boxtextcolor
Default:#000000
form.listBox.textFaceStringList boxtextfont name
Values:Courier / Helvetica / Times
Default:Courier
Note:If invalid, uses defaultfont
form.listBox.textSizeIntegerList boxtextfont size
Values:>=0
Default:0
Note:0 means auto-adjust font size
form.listBox.multipleSelectionBoolList box multi-select
Values:true / false
Default:false
Note: true enables multi-select
signature settings
signature.colorRGBSignature color
Default:#000000
signature.thicknessnumericSignature line thickness
Values:[1-12]
Default:8

Instantiate UIExtensionsManager with Configuration

In full-viewer and similar samples, a plain UIExtensionsManager loads all built-in UI. To apply JSON at init time:

Prerequisite

Place uiextensions_config.json under app/src/main/res/raw/ (create raw if needed).

In MainActivity.java:

java
import com.foxit.uiextensions.UIExtensionsManager;
import com.foxit.uiextensions.config.Config;

import java.io.InputStream;

// ...

private PDFViewCtrl pdfViewCtrl = null;
private UIExtensionsManager uiExtensionsManager = null;

// 初始化 PDFViewCtrl 对象
pdfViewCtrl = new PDFViewCtrl(this);

// 加载配置文件
InputStream stream = this.getApplicationContext()
        .getResources()
        .openRawResource(R.raw.uiextensions_config);
Config config = new Config(stream);

// 使用配置文件初始化 UIExtensionsManager,并关联到 PDFViewCtrl
uiExtensionsManager = new UIExtensionsManager(this.getApplicationContext(), pdfViewCtrl, config);
pdfViewCtrl.setUIExtensionsManager(uiExtensionsManager);
uiExtensionsManager.setAttachedActivity(this);
uiExtensionsManager.onCreate(this, pdfViewCtrl, savedInstanceState);

Examples: Customize UI via Configuration

From the complete_pdf_viewer sample:

Example 1: Disable Modules

Set readingbookmark and navigation to false:

json
{
  "modules": {
    "readingbookmark": false,
    "navigation": false
  }
}

Set disableLink to true:

json
{
  "permissions": {
    "runJavaScript": true,
    "copyText": true,
    "disableLink": true
  }
}

Example 3: Change Highlight Color to Red

Set highlight.color to #ff0000:

json
{
  "uiSettings": {
    "annotations": {
      "highlight": {
        "color": "#ff0000",
        "opacity": 1.0
      }
    }
  }
}