This component require a license, that includes the Advanced PDF module.
With this you can append an existing PDF file to the PDF file in the payload of the workflow. You need to have created a PDF in the payload prior to this with the component, create PDF document. The PDF that is appended has to an attachment in the workflow.
The input for the component is PDF, so it can only be selected if the workflow payload is PDF. The parameter is seen below:
Attachment name
As "Attachment name" specify the name of the attachment that should be appended to the payload PDF. If this is left blank, then the first available attachment is used (so it can be left blank, if you have only created one attachment).
Here is an example where the Append a PDF workflow component can be used.
The input file in this case contains a string, which contains the path to the folder, where none or many PDF files are placed. These PDF files are to be appended to the PDF file, that is the result of a merge between the input file and an InterFormNG2 template. The resulting PDF file is to be used as an attachment for an outgoing email.
The text in the input file looks e.g. like this: \\myserver\share\OUTPUTS\S02093255\0209325500100091024\WO, so the PDF files are found in this folder.
A workflow that can do this is described below. It has been divided into 3 parts in order to make it easier to understand.
The main workflow looks like this:
(The input component is not included above).
The top branch of the multicast ends with a call to the sub-workflow, AppendPDFs:
Each of the workflows are explained below:
A multi-cast is used as a way to first prepare the attachment and then send the email in the second branch.
Later this named property will be updated with the appended PDFs.
This lists the path of all the PDF files found into an XML file, which is now the new payload.
In the second branch of the main workflow the PDF has been prepared (this is covered in the sub-workflows below) and now we can setup the attachment with Resource to attachment:
- and finally send the email with Send an HTML email:
This sub-workflow first use the choice element to verify if there are any PDF files to append at all. The payload at this point is an XML, that contains all PDF files to append.
If there are any files, then this condition is true:
If this is true, then the variable, Index is prepared with the initial value, 1 for the coming repeat loop (with the component, Set multiple workflow variables):
Now we can do the repeat for all the waiting PDF files:
count(/files/file) calculates the number of files, that are found and we need to keep the value of the Index variable to increase it for each iteration - hence the activation of 'Keep variable values and payload between repeats'.
For each repeat we call the last sub-workflow, Append1PDF:
(This sub-workflow appends a single PDF file and returns back to this workflow).
The execution comes back and then we increment the Index variable for each repeat iteration with Set multiple workflow variables:
Here you might notice, that we need to use the number() function in order to execute a numeric operator to a workflow variable as the workflow variables are always a string.
If there are no PDF files to append, the bottom branch of the choice element is executed and here we restore the original PDF file from the named property to payload:
- and then save this PDF payload as a resource like it is done in the last sub-workflow:
The last workflow is described below:
First the workflow loads the current PDF file to append into an attachment with the command, From file to attachment:
The path /files/file/absolutePath refers to the XML file, that was previously created by the List filesystem component and the Index variable is used as a selector to select the current PDF.
Now the sub workflow restores the PDF file, that we want to append this PDF file to, that is done with the component, Named property to payload:
Now the new PDF file can be appended with the component, Append a PDF:
(This attach the PDF file in attachment.pdf to the current payload)
Now we can update the named property, FirstPDF with payload to named property:
(Now the FirstPDF contains the new PDF with the appended file).
Finally we also update a resource with the new PDF file with Save in resources:
With this the updated PDF file is available for the main workflow, where it can be attached to an email.