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": trueis 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 bymodules.annotationssub-keys. - To hide all annotation-related entries in Comment, disable both
modules.annotationsandmodules.attachment.
Example (relationship only):
json{ "modules": { "annotations": false, "attachment": false } }- Sub-keys under
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.
| Module | Description |
|---|---|
| readingbookmark | User-defined reading bookmarks |
| outline | PDF 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 |
| thumbnail | Thumbnails and page management |
| attachment | Document attachments and attachment annotations |
| Signature | Digital and handwriting signatures |
| fillSign | Fill flat (non-interactive) forms with text and symbols |
| search | Text search |
| navigation | Page navigation |
| form | Form filling and data import/export |
| selection | Text selection |
| encryption | PDF encryption |
| multipleSelection | Multi-select annotations |
Permission Configuration
Permission values are boolean. runJavaScript and copyText default to true; disableLink defaults to false.
| Permission | Description |
|---|---|
| runJavaScript | Allow JavaScript execution |
| copyText | Allow text copy |
| disableLink | Disable hyperlinks |
Basic UI Settings
| Parameter | Type | Description |
|---|---|---|
| Page display | ||
pageMode | String | Page display mode Values: Single / Facing / CoverLeft / CoverMiddle / CoverRight / ReflowDefault: SingleNote: Reflow is not supported for dynamic XFA |
continuous | Bool | Continuous single-page display Values: true / falseDefault: falseNote: Not used in Reflow mode |
zoomMode | String | Page zoom mode Values: FitWidth / FitPageDefault: FitWidth |
| Color and display | ||
colorMode | String | Page color mode Values: Normal / Night / MapDefault: NormalNote: Night is a special Map mode |
mapForegroundColor | RGB | Foreground color (Map only)Default: #5d5b71 |
mapBackgroundColor | RGB | Background color (Map only)Default: #00001b |
| Form and links | ||
disableFormNavigationBar | Bool | Disable form navigation bar Values: true / falseDefault: false |
highlightForm | Bool | Highlight form fields Values: true / falseDefault: true |
highlightFormColor | ARGB | Form highlight color Default: #200066ccNote: Includes alpha; not for dynamic XFA |
highlightLink | Bool | Highlight hyperlinks Values: true / falseDefault: true |
highlightLinkColor | ARGB | Link highlight color Default: #16007fffNote: Includes alpha |
Annotation settings (annotations)
| Parameter | Type | Description |
|---|---|---|
| General | ||
continuouslyAdd | Bool | Continuously add same annotation type Values: true / falseDefault: true |
| Text markup annotations | ||
highlight.color | RGB | Highlight color Default: #ffff00 |
highlight.opacity | numeric | Highlight opacity Values: [0.0-1.0]Default: 1.0 |
areaHighlight.color | RGB | Area highlight color Default: #ffff00 |
areaHighlight.opacity | numeric | Area highlight opacity Values: [0.0-1.0]Default: 1.0Note: Uses default when area exceeds page |
underline.color | RGB | Underlinecolor Default: #66cc33 |
underline.opacity | numeric | Underlineopacity Values: [0.0-1.0]Default: 1.0 |
squiggly.color | RGB | Squigglycolor Default: #993399 |
squiggly.opacity | numeric | Squigglyopacity Values: [0.0-1.0]Default: 1.0 |
strikeout.color | RGB | Strikethroughcolor Default: #ff0000 |
strikeout.opacity | numeric | Strikethroughopacity Values: [0.0-1.0]Default: 1.0 |
insert.color | RGB | Insert markcolor Default: #993399 |
insert.opacity | numeric | Insert markopacity Values: [0.0-1.0]Default: 1.0 |
replace.color | RGB | Replace markcolor Default: #0000ff |
replace.opacity | numeric | Replace markopacity Values: [0.0-1.0]Default: 1.0 |
| Shape annotations | ||
line.color | RGB | Linecolor Default: #ff0000 |
line.opacity | numeric | Lineopacity Values: [0.0-1.0]Default: 1.0 |
line.thickness | numeric | Linewidth Values: [1-12]Default: 2 |
rectangle.color | RGB | Rectanglebordercolor Default: #ff0000 |
rectangle.opacity | numeric | Rectangleopacity Values: [0.0-1.0]Default: 1.0 |
rectangle.thickness | numeric | Rectangleborderwidth Values: [1-12]Default: 2 |
rectangle.fillColor | RGB | Rectanglefill color Default: null |
oval.color | RGB | Ovalbordercolor Default: #ff0000 |
oval.opacity | numeric | Ovalopacity Values: [0.0-1.0]Default: 1.0 |
oval.thickness | numeric | Ovalborderwidth Values: [1-12]Default: 2 |
oval.fillColor | RGB | Ovalfill color Default: null |
arrow.color | RGB | Arrowcolor Default: #ff0000 |
arrow.opacity | numeric | Arrowopacity Values: [0.0-1.0]Default: 1.0 |
arrow.thickness | numeric | Arrowline width Values: [1-12]Default: 2 |
pencil.color | RGB | Pencilcolor Default: #ff0000 |
pencil.opacity | numeric | Pencilopacity Values: [0.0-1.0]Default: 1.0 |
pencil.thickness | numeric | Pencilthickness Values: [1-12]Default: 2 |
pencil.addHistoricalPoints | Bool | Whether to add historical points for current frame Values: true / falseDefault: true |
polygon.color | RGB | Polygonbordercolor Default: #ff0000 |
polygon.opacity | numeric | Polygonopacity Values: [0.0-1.0]Default: 1.0 |
polygon.thickness | numeric | Polygonborderwidth Values: [1-12]Default: 2 |
polygon.fillColor | RGB | Polygonfill color Default: null |
cloud.color | RGB | Cloudbordercolor Default: #ff0000 |
cloud.opacity | numeric | Cloudopacity Values: [0.0-1.0]Default: 1.0 |
cloud.thickness | numeric | Cloudborderwidth Values: [1-12]Default: 2 |
cloud.fillColor | RGB | Cloudfill color Default: null |
polyline.color | RGB | Polylinecolor Default: #ff0000 |
polyline.opacity | numeric | Polylineopacity Values: [0.0-1.0]Default: 1.0 |
polyline.thickness | numeric | Polylinewidth Values: [1-12]Default: 2 |
| Text annotations | ||
typewriter.textColor | RGB | Typewritertextcolor Default: #0000ff |
typewriter.opacity | numeric | Typewriteropacity Values: [0.0-1.0]Default: 1.0 |
typewriter.textFace | String | Typewriter font Values: Courier / Helvetica / TimesDefault: CourierNote:invalid value uses defaultfont |
typewriter.textSize | Integer | Typewriter font size Values: >=1Default: 18 |
textbox.color | RGB | Text boxbordercolor Default: #ff0000 |
textbox.textColor | RGB | Text boxtextcolor Default: #0000ff |
textbox.opacity | numeric | Text boxopacity Values: [0.0-1.0]Default: 1.0 |
textbox.textFace | String | Text box font Values: Courier / Helvetica / TimesDefault: CourierNote:invalid value uses defaultfont |
textbox.textSize | Integer | Text box font size Values: >=1Default: 18 |
callout.color | RGB | Calloutbordercolor Default: #ff0000 |
callout.textColor | RGB | Callouttextcolor Default: #0000ff |
callout.opacity | numeric | Calloutopacity Values: [0.0-1.0]Default: 1.0 |
callout.textFace | String | Callout font Values: Courier / Helvetica / TimesDefault: CourierNote:invalid value uses defaultfont |
callout.textSize | Integer | Callout font size Values: >=1Default: 18 |
| Other annotations | ||
note.color | RGB | Notecolor Default: #ff0000 |
note.opacity | numeric | Noteopacity Values: [0.0-1.0]Default: 1.0 |
note.icon | String | Note icon type Values: Comment / Key / Note / Help / NewParagraph / Paragraph / InsertDefault: CommentNote:invalid value uses default icon |
attachment.color | RGB | Attachmentcolor Default: #ff0000 |
attachment.opacity | numeric | Attachmentopacity Values: [0.0-1.0]Default: 1.0 |
attachment.icon | String | Attachment icon type Values: Graph / PushPin / Paperclip / TagDefault: PushPinNote:invalid value uses default icon |
image.rotation | numeric | Imagerotation Values: 0 / 90 / 180 / 270Default: 0 |
image.opacity | numeric | Imageopacity Values: [0.0-1.0]Default: 1.0 |
image.textSize | Integer | ImagetextCallout font size Values: >=1Default: 12 |
measure.color | RGB | Measure linecolor Default: #ff0000 |
measure.opacity | numeric | Measure lineopacity Values: [0.0-1.0]Default: 1.0 |
measure.thickness | numeric | Measure linewidth Values: [1-12]Default: 2 |
measure.scaleFromUnit | String | Scale from unit Values: pt / m / cm / mm / inch / p / ft / ydDefault: inchNote: Base unit for scale |
measure.scaleToUnit | String | Scale to unit Values: pt / m / cm / mm / inch / p / ft / ydDefault: inchNote: Target unit for scale |
measure.scaleFromValue | numeric | Scale from value Default: 1.0Note: Base value for scale |
measure.scaleToValue | numeric | Scale to value Default: 1.0Note: Target value for scale |
Form control settings (form)
| Parameter | Type | Description |
|---|---|---|
| form.textField settings | ||
form.textField.textColor | RGB | textcolor Default: #000000 |
form.textField.textFace | String | textfont name Values: Courier / Helvetica / TimesDefault: CourierNote:If invalid, uses defaultfont |
form.textField.textSize | Integer | textfont size Values: >=0Default: 0Note:0 means auto-adjust font size |
| form.checkBox settings | ||
form.checkBox.textColor | RGB | Checkboxtextcolor Default: #000000 |
| form.radioButton settings | ||
form.radioButton.textColor | RGB | Radio buttontextcolor Default: #000000 |
| form.comboBox settings | ||
form.comboBox.textColor | RGB | Combo boxtextcolor Default: #000000 |
form.comboBox.textFace | String | Combo boxtextfont name Values: Courier / Helvetica / TimesDefault: CourierNote:If invalid, uses defaultfont |
form.comboBox.textSize | Integer | Combo boxtextfont size Values: >=0Default: 0Note:0 means auto-adjust font size |
form.comboBox.customText | Bool | Combo box allow custom text Values: true / falseDefault: falseNote: true allows custom text |
| form.listBox settings | ||
form.listBox.textColor | RGB | List boxtextcolor Default: #000000 |
form.listBox.textFace | String | List boxtextfont name Values: Courier / Helvetica / TimesDefault: CourierNote:If invalid, uses defaultfont |
form.listBox.textSize | Integer | List boxtextfont size Values: >=0Default: 0Note:0 means auto-adjust font size |
form.listBox.multipleSelection | Bool | List box multi-select Values: true / falseDefault: falseNote: true enables multi-select |
| signature settings | ||
signature.color | RGB | Signature color Default: #000000 |
signature.thickness | numeric | Signature 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
}
}Example 2: Disable Hyperlinks
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
}
}
}
}