ftos.files.pdf.form.setFieldsReadOnly
Toggles the read-only flag for all fields (for all fields or for the fields specified by "fields" parameter, for all fields if "fields" parameter is not specified) in a PDF and saves the result to a new file. The end-user can’t modify the fields that are set to read-only using this method. Fields that were set as read-only with this SDK method, are still displayed in the server automation code sample.
The method throws exceptions that you can catch with try catch. In this case, your script keeps running, the error doesn’t block or kill execution.
This is a business logic method for business service components.
Syntax
ftos.files.pdf.form.setFieldsReadOnly(sourceRealName: string, outputFile: string, isReadOnly: boolean, formFields: string): any
| Parameters | Type | Description |
|---|---|---|
sourceRealName
|
string | The name of the source PDF file containing interactive form fields. |
outputFile
|
string | The name of the output PDF file where the updated form will be saved. |
isReadOnly
|
boolean | Set it to true to lock fields or false to unlock if the fields were previously made read-only. |
|
|
string |
Optional, if specified apply the change only to fields in this list (partial read only). |
Return Value
Returns the real name of the generated PDF.
The example takes a PDF document with interactive fields, retrieves the "FullName" field and sets it to read-only so that it can no longer be edited in the new PDF, while other fields remain editable. Then, it makes the newly generated PDF (output.pdf) available for download in the client/browser.
var formNs = ftos.files.pdf.form;
const fields = formNs.getFields("UpdateFilledFormWithSubmit_f1f82f1c-4ed1-4a1b-b3c9-53da1be0fbe3.pdf")
const readOnlyFile = formNs.setFieldsReadOnly("UpdateFilledFormWithSubmit_f1f82f1c-4ed1-4a1b-b3c9-53da1be0fbe3.pdf", "output.pdf", true, ["FullName"]);
setDownload(readOnlyFile);