Skip to content
Guides

UI Customization

In version 1.12.0, we have expanded the options defined in the configuration.json. When using the NativeModules.OpenPDFModule.openPDFByConfiguration method to open a PDF view, you can define the JSON content to meet your product requirements. We will continue to enrich the configuration options in the future to further enhance the flexibility of the product. Here are some examples of commonly used configuration options:

The following only shows the key parts of the example. Please pass in the complete json content when using it.

  1. Set the initial display mode and the list of available modes. The following code shows enabling only the viewer mode and annotations mode:
json
{
  "modeConfig": {
    "initialViewMode": "viewer",
    "availableViewModes": [
      "viewer",
      "annotations"
    ]
  },
  ... // other options
}
  1. Set the list of enabled annotation types and default annotation attribute values. For example, enable only highlight annotations and set the color and transparency for highlight annotations:
json
{
  "annotationsConfig": {
    "availableTypes": [
      "note"
    ],
    "availableTools": [
      "setting",
      "undo",
      "redo"
    ],
    "initAttribute": {
      "note": {
        "color": "#1460F3",
        "alpha": 255
      }
    }
  }
  ... // other options
}
  1. Set the display mode and page flipping direction:
json
{
  "readerViewConfig": {
    "displayMode": "doublePage",
    "verticalMode": false
  }
  ... // other options
}

The following is the complete configuration content with data description:

json
{
  "modeConfig": {
    "initialViewMode": "viewer",	// When initializing the display mode, nsure that the selected mode exists in the availableViewModes. Otherwise, it will default to the viewer mode. Refer to the availableViewModes field for valid values.
    "availableViewModes": [				// Only modes listed in the mode list will be displayed.
      "viewer",
      "annotations",
      "contentEditor",
      "forms",
      "signatures"
    ]
  },
  "toolbarConfig": {							// Top Toolbar Configuration
    "androidAvailableActions": [
      "thumbnail",
      "search",
      "bota",
      "menu"
    ],
    "iosLeftBarAvailableActions": [
      "back",
      "thumbnail"
    ],
    "iosRightBarAvailableActions": [
      "search",
      "bota",
      "menu"
    ],
    "availableMenus": [
      "viewSettings",
      "documentEditor",
      "documentInfo",
      "watermark",
      "security",
      "flattened",
      "save",
      "share",
      "openDocument"
    ]
  },
  "annotationsConfig": {			// Annotation Feature Configuration
    "availableTypes": [				// List of enabled annotation types for the bottom annotation functionality
      "note",
      "highlight",
      "underline",
      "squiggly",
      "strikeout",
      "ink",
      "pencil",								// only ios platform
      "circle",
      "square",
      "arrow",
      "line",
      "freetext",
      "signature",
      "stamp",
      "pictures",
      "link",
      "sound"
    ],
    "availableTools": [				// Annotation tools enabled for the bottom annotation functionality
      "setting",
      "undo",
      "redo"
    ],
    "initAttribute": {				// Default properties for annotations upon initialization, influencing attributes such as color, transparency, etc., when adding annotations.
      "note": {
        "color": "#1460F3",
        "alpha": 255					// Color transparency 0~255
      },
      "highlight": {
        "color": "#1460F3",
        "alpha": 77
      },
      "underline": {
        "color": "#1460F3",
        "alpha": 77
      },
      "squiggly": {
        "color": "#1460F3",
        "alpha": 77
      },
      "strikeout": {
        "color": "#1460F3",
        "alpha": 77
      },
      "ink": {
        "color": "#1460F3",
        "alpha": 100,
        "borderWidth": 10
      },
      "square": {
        "fillColor": "#1460F3",
        "borderColor": "#000000",
        "colorAlpha" : 128,
        "borderWidth": 2,
        "borderStyle": {
          "style": "solid",				// Border line styles: solid, dashed
          "dashGap": 0.0					// Dashed line interval length, applicable only when the style is set to 'dashed'.
        }
      },
      "circle": {
        "fillColor": "#1460F3",
        "borderColor": "#000000",
        "colorAlpha" : 128,
        "borderWidth": 2,
        "borderStyle": {
          "style": "solid",
          "dashGap": 0.0
        }
      },
      "line": {
        "borderColor": "#1460F3",
        "borderAlpha": 100,
        "borderWidth": 5,
        "borderStyle": {
          "style": "solid",
          "dashGap": 0.0
        }
      },
      "arrow": {
        "borderColor": "#1460F3",
        "borderAlpha": 100,
        "borderWidth": 5,
        "borderStyle": {
          "style": "solid",
          "dashGap": 0.0
        },
        "startLineType": "none",			// Starting arrow style options: none, openArrow, closedArrow, square, circle, diamond.
        "tailLineType": "openArrow" 	// tail arrow style options
      },
      "freeText": {
        "fontColor": "#000000",
        "fontColorAlpha": 255,
        "fontSize": 30,
        "isBold": false,
        "isItalic": false,
        "alignment": "left",				// left, center, right
        "typeface": "Helvetica"			// Courier, Helvetica, Times-Roman
      }
    }
  },
  "contentEditorConfig": {
    "availableTypes": [
      "editorText",
      "editorImage"
    ],
    "availableTools": [
      "setting",
      "undo",
      "redo"
    ],
    "initAttribute": {							// Default attributes for text type in content editing, influencing text properties when adding text.
      "text": {
        "fontColor": "#000000",
        "fontColorAlpha" : 100,
        "fontSize": 30,
        "isBold": false,
        "isItalic": false,
        "typeface": "Times-Roman",	// Courier, Helvetica, Times-Roman
        "alignment": "left"					// left, center, right
      }
    }
  },
  "formsConfig": {
    "availableTypes": [							// Types of forms displayed in the list of the bottom form toolbar.
      "textField",
      "checkBox",
      "radioButton",
      "listBox",
      "comboBox",
      "signaturesFields",
      "pushButton"
    ],
    "availableTools": [
      "undo",
      "redo"
    ],
    "initAttribute": {
      "textField": {
        "fillColor": "#DDE9FF",
        "borderColor": "#1460F3",
        "borderWidth": 2,
        "fontColor": "#000000",
        "fontSize": 20,
        "isBold": false,
        "isItalic": false,
        "alignment": "left",				// left, center, right
        "multiline": true,
        "typeface": "Helvetica"			// Courier, Helvetica, Times-Roman
      },
      "checkBox": {
        "fillColor": "#DDE9FF",
        "borderColor": "#1460F3",
        "borderWidth": 2,
        "checkedColor": "#43474D",
        "isChecked": false,
        "checkedStyle": "check"			// check, circle, cross, diamond, square, star
      },
      "radioButton": {
        "fillColor": "#DDE9FF",
        "borderColor": "#1460F3",
        "borderWidth": 2,
        "checkedColor": "#43474D",
        "isChecked": false,
        "checkedStyle": "circle"		// check, circle, cross, diamond, square, star
      },
      "listBox": {
        "fillColor": "#DDE9FF",
        "borderColor": "#1460F3",
        "borderWidth": 2,
        "fontColor": "#000000",
        "fontSize": 20,
        "typeface": "Helvetica",		// Courier, Helvetica, Times-Roman
        "isBold": false,
        "isItalic": false
      },
      "comboBox": {
        "fillColor": "#DDE9FF",
        "borderColor": "#1460F3",
        "borderWidth": 2,
        "fontColor": "#000000",
        "fontSize": 20,
        "typeface": "Helvetica",		// Courier, Helvetica, Times-Roman
        "isBold": false,
        "isItalic": false
      },
      "pushButton": {
        "fillColor": "#DDE9FF",
        "borderColor": "#1460F3",
        "borderWidth": 2,
        "fontColor": "#000000",
        "fontSize": 20,
        "title": "Button",
        "typeface": "Helvetica",		// Courier, Helvetica, Times-Roman
        "isBold": false,
        "isItalic": false
      },
      "signaturesFields": {
        "fillColor": "#DDE9FF",
        "borderColor": "#000000",
        "borderWidth": 2
      }
    }
  },
  "readerViewConfig": {
    "linkHighlight": true,
    "formFieldHighlight": true,
    "displayMode": "singlePage",		// singlePage, doublePage, coverPage
    "continueMode": true,
    "verticalMode": true,
    "cropMode": false,
    "themes" : "light",							// light, dark, sepia, reseda
    "enableSliderBar": true,
    "enablePageIndicator": true,
    "pageSpacing": 10,
    "pageScale": 1.0
  }
}