Constructor
new PDFField()
Example
let pdfDoc; // PDFDoc实例
let pdfForm = await pdfDoc.loadPDFForm();
let pdfField = await pdfForm.getField('fieldName');
Methods
(async) describeFieldFlags() → {Promise.<FieldFlagOptions>}
- Description:
Returns:
返回一个对象,描述表单域的各个标志属性及其布尔值。
-
Type
-
Promise.<FieldFlagOptions>
(async) getAlignment() → {Promise.<number>}
- Description:
Returns:
-
Type
-
Promise.<number>
(async) getAlternateName() → {Promise.<string>}
- Description:
Returns:
-
Type
-
Promise.<string>
getBorderColor()
- Description:
- 获取表单域的边框颜色(不支持签名域)。在调用此函数之前加载所有相对注释,否则将返回错误的值。
- Deprecated:
getBorderStyle()
- Description:
- 获取表单域的边框样式。在调用此函数之前加载所有相对注释,否则将返回错误的值。
- Deprecated:
getControlByIndex()
- Description:
- Deprecated:
getControlsCount()
- Description:
- Deprecated:
getFillColor()
- Description:
- 获取表单域的填充颜色。在调用此函数之前加载所有相对注释,否则将返回错误的值。
- Deprecated:
getFlags() → {number}
- Description:
- Deprecated:
Returns:
-
Type
-
number
(async) getMappingName() → {Promise.<string>}
- Description:
Returns:
-
Type
-
Promise.<string>
(async) getMaxLength() → {Promise.<number>}
- Description:
Returns:
-
Type
-
Promise.<number>
getName() → {string}
- Description:
Returns:
字段名称。
-
Type
-
string
- Description:
Returns:
选项数组。
-
Type
-
Array.<PDFField.BasicOptions>
- Description:
Returns:
表单域的类型。
-
Type
-
Constants.Field_Type
(async) getValue() → {Promise.<string>}
- Description:
Returns:
-
Type
-
Promise.<string>
- Description:
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
index |
number
|
<optional>
|
0
|
注释索引,默认值为0。 |
Returns:
表单域的注释对象。
-
Type
-
Promise.<Widget>
- Description:
Returns:
表单域的注释数量。
-
Type
-
Promise.<number>
(async) setAlignment(alignment) → {Promise.<void>}
- Description:
Parameters:
Returns:
-
Type
-
Promise.<void>
(async) setAlternateName(alternateName) → {Promise.<void>}
- Description:
- 设置表单域的备用名称。此名称会在 UI 提示/错误/状态消息中代替真实字段名显示,也可用于辅助功能场景。
Parameters:
| Name |
Type |
Description |
alternateName |
string
|
备用名称。 |
Returns:
-
Type
-
Promise.<void>
setBorderColor()
- Description:
- 设置表单域的边框颜色(不支持签名域)。在调用此函数之前加载所有相对注释,否则将返回错误的值。
- Deprecated:
setBorderStyle()
- Description:
- 设置表单域的边框样式。在调用此函数之前加载所有相对注释,否则将返回错误的值。
- Deprecated:
setFillColor()
- Description:
- 设置表单域的填充颜色(不支持签名域)。在调用此函数之前加载所有相对注释,否则将返回错误的值。
- Deprecated:
(async) setFlags(flags) → {Promise.<void>}
- Description:
- Deprecated:
Parameters:
Returns:
-
Type
-
Promise.<void>
(async) setMappingName(mappingName) → {Promise.<void>}
- Description:
- 设置映射名称(不支持签名域)。该名称在导出交互式表单域数据时使用。
Parameters:
| Name |
Type |
Description |
mappingName |
string
|
映射名称。 |
Returns:
-
Type
-
Promise.<void>
(async) setMaxLength(maxLength) → {Promise.<void>}
- Description:
Parameters:
| Name |
Type |
Description |
maxLength |
number
|
最大字符数。 |
Returns:
-
Type
-
Promise.<void>
(async) setOptions(options) → {Promise.<void>}
- Description:
- 设置列表框或组合框的选项(项目)。仅适用于列表框或组合框类型字段。
Example
let options = [{
label: 'test',
value: "111",
selected: false,
defaultSelected: false,
},{
label: 'label',
value: "222",
selected: false,
defaultSelected: true,
}]
pdfField.setOptions(options);
Parameters:
Returns:
-
Type
-
Promise.<void>
(async) setValue(value) → {Promise.<void>}
- Description:
Parameters:
| Name |
Type |
Description |
value |
string
|
值。 |
Returns:
-
Type
-
Promise.<void>
(async) updateFlagByOptions(options) → {Promise.<void>}
- Description:
Example
// 将字段设置为只读和必填
await pdfField.updateFlagByOptions({
readonly: true,
required: true,
});
Parameters:
Returns:
-
Type
-
Promise.<void>
Type Definitions
BasicOptions
Properties:
| Name |
Type |
Description |
label |
string
|
显示的选项值。 |
value |
string
|
选项值。 |
selected |
boolean
|
是否已选中。 |
defaultSelected |
boolean
|
是否默认选中。 |
Type: