Skip to content

Latest commit

 

History

History
64 lines (44 loc) · 3.69 KB

README.md

File metadata and controls

64 lines (44 loc) · 3.69 KB

PDF functions

Set fields in PDF file (base64) and generate filled-in PDF

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:

img.png

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:

img_1.png

To discover the actual fields names of a PDF file, there are a couple of options:

  1. Use the pdftk command line tool
  2. 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.

Java code info

Function rule configuration

  • 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

Set fields in PDF file (URL) and generate filled-in PDF

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:

img.png

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:

img_1.png

To discover the actual fields names of a PDF file, there are a couple of options:

  1. Use the pdftk command line tool
  2. 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.

Java code info

Function rule configuration

  • 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