跳到主要内容

SetReadOnly

设置字段为只读

语法

expression.SetReadOnly(readOnly);

expression - 表示 ApiBaseField 类的变量。

参数

名称必需/可选数据类型默认值描述
readOnly必需boolean指定字段是否为只读。

返回值

boolean

示例

锁定 PDF 中的表单字段以防止编辑。

// How do I make a form field read-only in a PDF?

// Disable editing on a form field in a PDF.

let doc = Api.GetDocument();
let page = doc.GetPage(0);
let textField = Api.CreateTextField([10, 10, 160, 30]);
page.AddObject(textField);

textField.SetReadOnly(true);
textField.SetValue('Read only is: ' + textField.IsReadOnly());