This method takes a base64-encoded PDF form, and a json string containing field->value mappings, and returns a base64-encoded PDF with those fields filled in as specified.
For the below example, a sample PDF with two text fields is used as the input:
The output is base64 encoded, and can be passed to the platform attachment function CreateAdHocFileAttachment
to create a file and attach it to the current case:
To discover the actual fields names of a PDF file, there are a couple of options:
- Use the pdftk command line tool
- Use the pdfbox java library to iterate through all fields in a form and set the value of that field to the qualified name of the field.
- Class: com.pega.launchpad.pdf.PDF
- Method: setFieldsWithBase64
- Function handler: com.pega.launchpad.pdf.PDF::setFieldsWithBase64
- Input parameters:
- inputForm (Text): Base64-encoded PDF document that has form elements.
- fieldJson (Text): Single json object that specifies the fields and values to set. Example for the sample PDF:
{"fieldsContainer.nestedSampleField":"Value for nestedSampleField","sampleField":"Value for sampleField"}
- Output parameters:
- Type: Text: The base64-encoded PDF with the specified fields set to the specified value
This method takes the URL for a PDF file, and a json string containing field->value mappings, and returns a base64-encoded PDF with those fields filled in as specified.
For the below example, a sample PDF from a URL with two text fields is used as the input:
The output is base64 encoded, and can be passed to the platform attachment function CreateAdHocFileAttachment
to create a file and attach it to the current case:
To discover the actual fields names of a PDF file, there are a couple of options:
- Use the pdftk command line tool
- Use the pdfbox java library to iterate through all fields in a form and set the value of that field to the qualified name of the field.
- Class: com.pega.launchpad.pdf.PDF
- Method: setFieldsWithURL
- Function handler: com.pega.launchpad.pdf.PDF::setFieldsWithURL
- Input parameters:
- inputURL (Text): A valid URL that points to a PDF document with form elements.
- fieldJson (Text): Single json object that specifies the fields and values to set. Example for the sample PDF:
{"fieldsContainer.nestedSampleField":"Value for nestedSampleField","sampleField":"Value for sampleField"}
- Output parameters:
- Type: Text: The base64-encoded PDF with the specified fields set to the specified value