Skip to main content

SetReadOnly

Sets field read only

Syntax

expression.SetReadOnly(readOnly);

expression - A variable that represents a ApiBaseField class.

Parameters

NameRequired/OptionalData typeDefaultDescription
readOnlyRequiredbooleanSpecifies whether the field is read-only.

Returns

boolean

Example

Lock a form field to prevent editing in a 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());