ftos.files.pdf.form.setFields
Updates multiple form fields and persists the edited PDF under a new name.
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.setFields(sourceRealName: string, outputFile: string, formData: any): string
| 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. |
formData
|
any | Key-value pairs representing form field names and their values. |
Return Value
The method returns the file name of the resulting PDF, specifically, the name of the that was created after updating the form fields.
The example takes a PDF with interactive fields, writes "John Doe" into the "FullName" field, outputs a new PDF (modifiedfile.pdf) with that field updated, and could optionally, download
const modifiedFile= formNs.setFields(readOnlyFile, "modifiedfile.pdf", {"FullName": "John Doe"});
//setDownload(modifiedFile);
//setMessage(fields[0].name);