Fill PDF form
The service task "Fill PDF form" enters values from the process into the text fields of a fillable PDF form and saves the result as a new file. It suits given forms that are not to be redesigned, such as official forms or certificates. For freely designed documents, Generate PDF from template is the right service.
Technical name prio_pdfFillForm · Category in the "Select service task" dialog: Documents & PDF
When is this service used?
- Certificates of attendance: After a training, Musterfirma GmbH fills its certificate form with name, training title and date.
- Third-party forms: A form from a manufacturer or an authority is pre-filled with customer data and sent to the customer for signature.
- Maintenance reports: A report form is pre-filled with device and customer data, the technician adds the rest.
Prerequisites
The PDF has to be a real form with named fields (AcroForm). Only text fields are filled; checkboxes, dropdowns and radio buttons stay unchanged. The field names are shown in the form view of a PDF program and have to be written in formData exactly like that, including upper and lower case.
Input
| Field | Type | Required | Meaning |
|---|---|---|---|
pdf |
file object | yes | The form PDF as {referenceId, filename, contentType} |
formData |
object | yes | Mapping field name → value. Values have to be text; format numbers and dates beforehand with $string() or $fromMillis() |
{
"pdf": template.certificate,
"formData": {
"participant_name": participant.firstName & " " & participant.lastName,
"training_title": training.title,
"training_date": $fromMillis($toMillis(training.date), "[D01].[M01].[Y0001]"),
"location": "Augsburg"
}
}
Output
{
"filename": "certificate.pdf",
"referenceId": "01JCX4R9M2T7V8W3Y5Z6A7B8C9",
"contentType": "application/pdf"
}
A file object for the new file in the Pantarey storage. filename is the name of the template; the fields stay editable, the form is not flattened. The original is not changed. The result is stored under the result path, e.g. certificate.
For an own file name, the result is renamed in the output expression:
{ "referenceId": referenceId, "contentType": contentType, "filename": "Certificate-" & $$.participant.lastName & ".pdf" }
Errors and behavior
- Missing input throws
No PDF provided for form filling; a PDF that cannot be loaded throws on loading. With an error boundary event the process continues there; without one the instance ends in error with a resume point and an error email to the process owner. - Field errors are silent: An unknown field name, a field that is not a text field, or a value that is not text is skipped; the field stays empty, the step counts as successful. A PDF without a form returns an unchanged copy. The service does not report which fields were filled.
- The service never returns
{status, message}. - Time limit 900 seconds. A new file is saved; retries for transient errors (up to three attempts) at worst create a second file, but no harm.
- In the dry run no file is created; the step returns a sample output from the catalog.
Example
After a training, Musterfirma GmbH creates a certificate per participant. The template is kept as a process value or in the training record under template.certificate; the message contains participant and training.
- Input expression as above, with four text fields of the form.
- Output expression renames the file, result path
certificate. - Output:
{ "filename": "Certificate-Huber.pdf", "referenceId": "01JC…", "contentType": "application/pdf" }. - Next step: Send email to external recipients (own domain) with
certificateas attachment; then a database step saves the file on the participant record.
Frequently asked questions
The file is there, but some fields are empty.
The field name in formData does not exactly match the name in the PDF (including upper/lower case), the field is not a text field, or the value was not text. Such fields are skipped without an error message.
Can checkboxes be ticked?
No, only text fields are filled. Checkboxes, radio buttons and dropdowns stay as they are in the template.
Should the form be no longer editable after filling?
The fields stay editable. The service does not offer flattening the fields.
Next step
Generate PDF from template: create freely designed PDFs from an HTML template with Handlebars.