PDFForm

PDFForm

PDFForm类

Constructor

new PDFForm()

Example
let pdfDoc; // PDFDoc实例
let pdfForm = await pdfDoc.loadPDFForm();

Methods

addControl()

Description:
  • 将新的表单控件添加到指定的表单域。如果表单域不存在,此函数也将添加一个表单域。(不支持签名域)。
Deprecated:

addSignature()

Description:
  • 添加未签名的签名域。
Deprecated:

(async) createCheckbox(options) → {Promise.<Widget>}

Description:
  • 创建一个复选框控件
Parameters:
Name Type Description
options PDFForm.CreateWidgetOptions 创建表单控件的选项
Returns:
Type
Promise.<Widget>

(async) createComboBox(options) → {Promise.<Widget>}

Description:
  • 创建一个下拉列表控件
Parameters:
Name Type Description
options PDFForm.CreateWidgetOptions 创建表单控件的选项
Returns:
Type
Promise.<Widget>

(async) createDatetime(options) → {Promise.<Widget>}

Description:
  • 创建一个日期时间控件
Parameters:
Name Type Description
options PDFForm.CreateDatetimeOptions 创建日期时间控件的选项
Returns:
Type
Promise.<Widget>

(async) createImageButton(options) → {Promise.<Widget>}

Description:
  • 创建一个图像按钮控件
Parameters:
Name Type Description
options PDFForm.CreateImageOptions 创建图像按钮控件的选项,必须包含imagePath属性,表示图像的URL路径
Returns:
Type
Promise.<Widget>

(async) createListBox(options) → {Promise.<Widget>}

Description:
  • 创建一个列表框控件
Parameters:
Name Type Description
options PDFForm.CreateWidgetOptions 创建表单控件的选项
Returns:
Type
Promise.<Widget>

(async) createPushButton(options) → {Promise.<Widget>}

Description:
  • 创建一个按钮控件
Parameters:
Name Type Description
options PDFForm.CreateWidgetOptions 创建表单控件的选项
Returns:
Type
Promise.<Widget>

(async) createRadioButton(options) → {Promise.<Widget>}

Description:
  • 创建一个单选按钮控件
Parameters:
Name Type Description
options PDFForm.CreateWidgetOptions 创建表单控件的选项
Returns:
Type
Promise.<Widget>

(async) createSignature(options) → {Promise.<Widget>}

Description:
  • 创建一个签名控件
Parameters:
Name Type Description
options PDFForm.CreateWidgetOptions 创建表单控件的选项
Returns:
Type
Promise.<Widget>

(async) createTextField(options) → {Promise.<Widget>}

Description:
  • 创建一个文本字段控件
Parameters:
Name Type Description
options PDFForm.CreateWidgetOptions 创建表单控件的选项
Returns:
Type
Promise.<Widget>

(async) exportFormToFile(fileType) → {Promise.<void>}

Description:
  • 将文档表单数据导出到文件
Example
let embedView; // View实例
let fileType; // 文件类型
let pdfForm = await embedView.pdfDoc.loadPDFForm();
pdfForm.exportFormToFile(fileType);
Parameters:
Name Type Description
fileType number 文件类型,0: FDF, 1: XFDF, 2: XML, 3: CSV, 4: TXT, 5: JSON
Returns:
Type
Promise.<void>

(async) getField(fieldName) → {Promise.<(PDFField|undefined)>}

Description:
  • 获取由名称指定的表单域
Parameters:
Name Type Description
fieldName string 表单域名称
Returns:
Type
Promise.<(PDFField|undefined)>

getFieldByIndex()

Description:
  • 获取由索引指定的表单域。
Deprecated:

getFieldCount()

Description:
  • 获取表单签名域的计数,包括不支持的签名域。
Deprecated:

(async) getFields() → {Promise.<Array.<PDFField>>}

Description:
  • 获取PDF所有表单域
Returns:
Type
Promise.<Array.<PDFField>>

(async) importFormFromFile(file, fileType) → {Promise.<void>}

Description:
  • 从文件导入表单数据。
Example
let embedView; // View实例
let file = e.target.files[0]; // <input type="file">标签选取的文件
let fileType; // 文件类型
let pdfForm = await embedView.pdfDoc.loadPDFForm();
pdfForm.importFormFromFile(file, fileType);
Parameters:
Name Type Description
file File | Blob 要导入的文件或Blob对象
fileType number 文件类型,0: FDF, 1: XFDF, 2: XML, 3: CSV, 4: TXT, 5: JSON
Returns:
Type
Promise.<void>

removeField()

Description:
  • 移除指定的表单域。
Deprecated:

Type Definitions

CreateDatetimeOptions

Properties:
Name Type Attributes Description
pageIndex number 页面索引,从0开始
pdfRect Rect 表单控件在PDF页面上的位置和大小
fieldName string <optional>
可选的表单域名称,如果未提供,系统将自动生成一个唯一的名称
timeformat string <optional>
可选的时间格式字符串,指定日期时间控件的显示格式
Type:
  • Object

CreateImageOptions

Properties:
Name Type Attributes Description
pageIndex number 页面索引,从0开始
pdfRect Rect 表单控件在PDF页面上的位置和大小
fieldName string <optional>
可选的表单域名称,如果未提供,系统将自动生成一个唯一的名称
imagePath string 图像的URL路径,用于创建图像按钮控件
Type:
  • Object

CreateWidgetOptions

Properties:
Name Type Attributes Description
pageIndex number 页面索引,从0开始
pdfRect Rect 表单控件在PDF页面上的位置和大小
fieldName string <optional>
可选的表单域名称,如果未提供,系统将自动生成一个唯一的名称
Type:
  • Object