uiextensions_config.json 配置说明
本文说明福昕 PDF SDK 鸿蒙版 UIExtensions 配置文件的配置项、默认值、可选值与含义。如何加载配置并做常见定制,见 使用配置文件自定义 UI。
对应样例文件(发版包):
samples/complete_pdf_viewer/entry/src/main/resources/rawfile/uiextensions_config.json
- 集成时可将该文件复制到自有工程 rawfile,再按本文修改所需项。
- 发版包内亦可查阅同内容的
docs/uiextensions_config.md;更细的 API / 类型定义见包内 API Reference,以及 UIExtensions 源码libs/uiextensions/.../config/UIExtensionsConfig.ets。
未在配置文件中写出的字段,使用 SDK 内置默认值。
使用注意
颜色字符串支持
#RRGGBB或#AARRGGBB(含透明度)。根级仅识别三个对象:
modules、permissions、uiSettings。建议在完整样例配置上修改取值。若自行删减
uiSettings.annotations、uiSettings.form、modules.annotations等嵌套对象中的子项,被删掉的子项不会再回落到 SDK 默认值。例如仅写出:json"uiSettings": { "annotations": { "highlight": { "color": "#00ff00", "opacity": 1.0 } } }则
annotations会被整段替换为上述内容,结果只保留highlight;continuouslyAdd、underline、note等其它子项不会自动补回。模块开关关闭后,对应工具栏 / 面板入口通常不可用;实际能力仍受文档权限与授权影响。
1. modules — 功能模块开关
类型均为 boolean,可选值:true / false。
1.1 顶层模块
| 配置项 | 默认值 | 说明 |
|---|---|---|
modules.readingbookmark | true | 阅读书签 |
modules.outline | true | 文档大纲 |
modules.thumbnail | true | 页面缩略图 |
modules.attachment | true | 附件面板 / 附件类注释相关能力 |
modules.signature | true | 数字签名 |
modules.fillSign | true | 填写并签名(Fill & Sign) |
modules.search | true | 搜索面板 |
modules.pagenavigation | true | 页面导航 |
modules.form | true | 表单填写 |
modules.selection | true | 选择工具(页面文本选择) |
modules.encryption | true | 文件加密 / 保护相关入口 |
modules.multipleSelection | true | 注释多选 |
1.2 modules.annotations — 注释工具开关
| 配置项 | 默认值 | 说明 |
|---|---|---|
highlight | true | 高亮 |
underline | true | 下划线 |
squiggly | true | 波浪线 |
strikeout | true | 删除线 |
insert | true | 插入文本(Caret) |
replace | true | 替换文本(Caret) |
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 | 视频 |
redaction | true | 密文(Redaction) |
全部注释工具均为
false时,注释相关模块不会加载。
2. permissions — 权限开关
类型均为 boolean,可选值:true / false。
最终行为还受 PDF 文档自身权限约束。
| 配置项 | 默认值 | 说明 |
|---|---|---|
permissions.copyText | true | 是否允许复制页面文本 |
permissions.runJavaScript | true | 是否启用 JavaScript |
permissions.enableLink | true | 是否启用链接跳转 / 链接操作 |
permissions.copyAnnot | false | 是否允许复制注释 |
3. uiSettings — 界面与阅读设置
3.1 页面布局与缩放
| 配置项 | 类型 | 默认值 | 可选值 | 说明 |
|---|---|---|---|---|
uiSettings.pageMode | string | "Single" | Single / Facing / Cover / Reflow | 页面布局:单页 / 双页 / 封面模式 / 重排。非法值将被忽略 |
uiSettings.continuous | boolean | false | true / false | 是否连续滚动 |
uiSettings.zoomMode | string | "FitWidth" | FitWidth / FitHeight / FitPage | 初始缩放模式。非法值将被忽略 |
3.2 颜色与高亮
| 配置项 | 类型 | 默认值 | 可选值 / 约束 | 说明 |
|---|---|---|---|---|
uiSettings.colorMode | string | "Normal" | Normal / Night / Map | PDF 页面颜色模式:白天 / 夜间 / 自定义映射(与系统 UI 深色主题不同) |
uiSettings.mapForegroundColor | string | "#FF5d5b71" | #RRGGBB / #AARRGGBB | colorMode 为 Map 时的前景色 |
uiSettings.mapBackgroundColor | string | "#FF00001b" | 同上 | colorMode 为 Map 时的背景色 |
uiSettings.reflowBackgroundColor | string | "#FFFFFFFF" | 同上 | 重排模式背景色 |
uiSettings.pdfViewBackgroundColor | string | 未设置 | 颜色字符串,可省略 | PDF 视图背景色(可选) |
uiSettings.highlightForm | boolean | true | true / false | 是否高亮表单域 |
uiSettings.highlightFormColor | string | "#200066cc" | 颜色字符串 | 表单域高亮色 |
uiSettings.highlightLink | boolean | true | true / false | 是否高亮链接 |
uiSettings.highlightLinkColor | string | "#16007fff" | 颜色字符串 | 链接高亮色 |
3.3 工具栏与交互
| 配置项 | 类型 | 默认值 | 可选值 | 说明 |
|---|---|---|---|---|
uiSettings.fullscreen | boolean | true | true / false | 是否启用全屏相关能力(与点击显隐工具栏等配合) |
uiSettings.enableTapToToggleToolbar | boolean | true | true / false | 点击阅读页空白是否切换顶栏 / 底栏显隐 |
uiSettings.showPenOnlySwitch | boolean | true | true / false | 墨迹属性栏是否显示「仅触控笔」开关 |
uiSettings.enableFormNavigationBar | boolean | true | true / false | 是否显示表单域导航条 |
uiSettings.enablePageSlider | boolean | true | true / false | 是否显示页码滑动条 |
uiSettings.enableTopbarDraggable | number | 2 | 0 / 1 / 2 / 3 | 顶栏是否可拖动(见下表) |
enableTopbarDraggable 取值
| 值 | 含义 |
|---|---|
0 | 全部设备关闭 |
1 | 仅手机开启 |
2 | 仅平板开启(默认) |
3 | 手机与平板均开启 |
4. uiSettings.annotations — 注释默认属性
4.1 通用字段约定
| 字段 | 类型 | 推荐范围 / 可选值 | 说明 |
|---|---|---|---|
color / textColor / fillColor | string | #RRGGBB / #AARRGGBB;fillColor 可为 null | 描边色 / 文本色 / 填充色 |
opacity | number | 0.0~1.0 | 不透明度 |
thickness | number | 1~12(线条 / 形状类注释常用) | 线宽;铅笔等工具在界面中可能允许更大范围 |
textFace | string | Courier / Helvetica / Times | 字体 |
textSize | number | 注释工具:> 0;表单见第 5 节 | 字号(pt) |
stylusOnly | boolean | true / false | 铅笔是否默认仅触控笔输入 |
rotation | number | 0 / 90 / 180 / 270 | 图片注释旋转角度 |
scaleFromUnit / scaleToUnit | string | pt / inch / ft / yd / p / mm / cm / m | 测量比例单位;无法识别时回退为 pt |
scaleFromValue / scaleToValue | number | 正数 | 测量比例数值 |
4.2 连续添加
| 配置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
uiSettings.annotations.continuouslyAdd | boolean | true | 创建注释后是否保持当前工具,便于连续添加 |
4.3 各注释类型默认值
| 配置项 | 主要字段与默认值 |
|---|---|
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 / oval / polygon / cloud | color: "#ff0000",opacity: 1.0,thickness: 2,fillColor: null |
arrow / polyline | color: "#ff0000",opacity: 1.0,thickness: 2 |
pencil | color: "#ff0000",opacity: 1.0,thickness: 2,stylusOnly: false |
typewriter | textColor: "#0000ff",opacity: 1.0,textFace: "Courier",textSize: 18 |
textbox / 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/scaleToUnit: "inch",scaleFromValue/scaleToValue: 1.0 |
redaction | fillColor: "#000000",textColor: "#ff0000",textFace: "Courier",textSize: 12 |
4.4 便签图标 note.icon
可选值:
Check / Circle / Comment / Cross / Help / Insert / Key / NewParagraph / Note / Paragraph / RightArrow / RightPointer / Star / UpArrow / UpLeftArrow
默认:Comment
4.5 附件图标 attachment.icon
可选值:Graph / PushPin / Paperclip / Tag
默认:PushPin
5. uiSettings.form — 表单域默认属性
| 配置项 | 主要字段 | 默认值 | 说明 |
|---|---|---|---|
form.textField | textColor / textFace / textSize | "#000000" / "Courier" / 0 | textSize 为 0 表示自动字号(>= 0) |
form.checkBox | textColor | "#000000" | 复选框 |
form.radioButton | textColor | "#000000" | 单选框 |
form.comboBox | textColor / textFace / textSize / customText | "#000000" / "Courier" / 0 / false | customText:是否允许自定义输入 |
form.listBox | textColor / textFace / textSize / multipleSelection | "#000000" / "Courier" / 0 / false | multipleSelection:是否允许多选 |
textFace 可选值同注释:Courier / Helvetica / Times。
6. uiSettings.signature — 签名外观默认值
| 配置项 | 类型 | 默认值 | 约束 | 说明 |
|---|---|---|---|---|
uiSettings.signature.color | string | "#000000" | 颜色字符串 | 创建签名时的墨迹颜色 |
uiSettings.signature.thickness | number | 8 | 使用时若 < 2 会按 2 处理 | 笔画粗细 |
7. 枚举速查
| 配置项 | 可选值 |
|---|---|
pageMode | Single、Facing、Cover、Reflow |
zoomMode | FitWidth、FitHeight、FitPage |
colorMode | Normal、Night、Map |
enableTopbarDraggable | 0、1、2、3 |
textFace | Courier、Helvetica、Times |
测量单位(scaleFromUnit / scaleToUnit) | pt、inch、ft、yd、p、mm、cm、m |
note.icon | Check、Circle、Comment、Cross、Help、Insert、Key、NewParagraph、Note、Paragraph、RightArrow、RightPointer、Star、UpArrow、UpLeftArrow |
attachment.icon | Graph、PushPin、Paperclip、Tag |
image.rotation | 0、90、180、270 |
opacity | 0.0~1.0 |
thickness(线条 / 形状类常见) | 1~12 |