Illustrated in the below image is a flow where a Record Generator Source Step is used to present the PDF array fields. The Split PDF Writer step is used to split the PDF file. The Calculator step after the Split PDF writer step is used to capture the output as an array of base64 strings correlating to the pages in the PDF.
The Split step is used to split the output which is an array. The Calculator step after the Split mapper step is used to convert the record to a buffer. An SFTP Server destination step is used to save the PDF files that were created from the one PDF file which was split.
The image below is an example of a PDF document that will be split into 2 PDF files since it contains 2 pages.
Adding a Split PDF Writer Step
To add a Split PDF Writer step in a flow, follow the below instructions:
1. Click on the highlighted icon as shown in the below image.
2. The below page will appear. Select or search for a Writer step to pull out the source data. Click on the Writer tab and select Split PDF as shown in the image below.
Configuring a Split PDF Writer Step
Illustrated in the below image is the configuration that is available in the Split PDF Writer step.
From Field section β Retrieves the value from a field on the record.
Is Base64 checkbox β The retrieved value from a field on the record is Base64 encoded.
Using a Split PDF Writer Step
The image below shows data in the Record Generator step. The PDF documents are referenced as Base64 strings.
2. The Split PDF writer step is added to the flow.
3. The Calculator step is added after the Split PDF writer step to capture the output as an array of base64 strings correlating to the pages in the PDF. The page below illustrates the code that is used.
The output after the Calculator step is shown in the image below.
4. The Split step is added after the Calculator step to split the output which is an array which is shown in the below image.
Illustrated on the page below is the output after the Split step.
5. The Calculator step is added after the Split mapper step to convert the record to a buffer. The JSON code is illustrated in the below image. Line 13 generates a unique ID as the file name and adds the PDF file extension.
The output after the Calculator step is shown in the image below.
Viewing the created PDF file
1. Click the Execute Flow button shown in the image below:
2. Click the Create Run button.
3. The PDF document will be saved on the SFTP Server Destination step where it can be downloaded after the run has finished processing. The SFTP Server Destination Step configuration is illustrated in the image below. The Path field contains the path with the path extension {@record.path} that was created in the previous Calculator step.
The images below are the 2 PDF files that were created and sent to the SFTP Server.