GetFieldByName
按名称获取字段。
语法
expression.GetFieldByName(name);
expression - 表示 ApiDocument 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| name | 必需 | string | 完整名称参数。 |
返回值
示例
按名称在 PDF 中查找特定表单字段。
// How do I search for a field using its assigned name in a PDF?
// Retrieve a field and set its value by name in a PDF.
let doc = Api.GetDocument();
let page = doc.GetPage(0);
let textField = Api.CreateTextField([10, 10, 160, 30]);
page.AddObject(textField);
textField.SetName('Text field 1');
textField = doc.GetFieldByName('Text field 1');
textField.SetValue('Example value');