PDF 生成模板编辑器
开源可视化 PDF 生成引擎,支持自定义模板,并提供面向开发者的 API,灵活构建文档生成流程。
内容编辑模式允许用户直接编辑 PDF 页面中的文字和图片。通过 ContentEditorConfig 可配置可编辑类型、工具按钮和默认文本属性。
availableTypes 控制内容编辑工具栏中显示的编辑类型:
{
"contentEditorConfig": {
"availableTypes": [
"editorText",
"editorImage"
]
}
}| 值 | 说明 |
|---|---|
editorText | 编辑文本区域 |
editorImage | 编辑图片区域 |
{
"contentEditorConfig": {
"availableTools": [
"setting",
"undo",
"redo"
]
}
}| 值 | 说明 |
|---|---|
setting | 属性设置按钮 |
undo | 撤销 |
redo | 重做 |
通过 initAttribute 配置新建文本区域时的默认属性:
{
"contentEditorConfig": {
"initAttribute": {
"text": {
"fontColor": "#000000",
"fontColorAlpha": 255,
"fontSize": 30,
"isBold": false,
"isItalic": false,
"alignment": "left",
"familyName": "Helvetica",
"styleName": "Regular"
}
}
}
}| 字段 | 说明 |
|---|---|
fontColor | 文字颜色 |
fontColorAlpha | 文字不透明度(0-255) |
fontSize | 字号 |
isBold | 是否加粗 |
isItalic | 是否斜体 |
alignment | 对齐方式:"left"、"center"、"right" |
familyName | 字体名称 |
styleName | 字体样式 |
CEditToolbar 是内容编辑工具栏的核心 UI 组件,位于 com.compdfkit.tools.contenteditor.pdfcontenteditorbar 包中。
| 类 | 说明 |
|---|---|
CEditToolbar | 内容编辑工具栏主视图 |
CContentEditorToolListAdapter | 编辑类型列表适配器 |
CContentEditorToolBean | 编辑工具项数据模型 |
| 编辑类型 | Fragment 类 |
|---|---|
| 文本 | CEditTextPropertiesFragment |
| 图片 | CEditImagePropertiesFragment |
内容编辑模式下选中图片后,上下文菜单支持以下操作:
这些操作通过 上下文菜单 的 contentEditorMode 配置控制。