Please enable JavaScript to view this site.

InterFormNG2 Manual

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:

 

NG2AppendAPDF0001

 

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).

 

 

Example1: Append PDF files into one email 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:

 

NG2AppendPDF0002

(The input component is not included above).

 

 

The top branch of the multicast ends with a call to the sub-workflow, AppendPDFs:

NG2AppendPDF0003

 

 

The sub-workflow above calls the sub-workflow, Append1PDF in the first branch:

 

NG2AppendPDF0004

 

 

Each of the workflows are explained below:

 

The main workflow

A multi-cast is used as a way to first prepare the attachment and then send the email in the second branch.

 

The main workflow first create a PDF file in the payload with the component, Create PDF document:

 

NG2AppendPDF0005

 

Then the payload is saved into the named property, FirstPDF:

 

NG2AppendPDF0006

Later this named property will be updated with the appended PDFs.

 

The next element lists all the PDF files to append with the component, List filesystem:

 

NG2AppendPDF0007

This lists the path of all the PDF files found into an XML file, which is now the new payload.

 

Now the sub-workflow, AppendPDFs is called:

 

NG2AppendPDF0020

 

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:

 

NG2AppendPDF0021

 

- and finally send the email with Send an HTML email:

 

NG2AppendPDF0022

 

 

 

The sub-workflow: AppenPDFs

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:

 

NG2AppendPDF0008

 

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):

 

NG2AppendPDF0009

 

Now we can do the repeat for all the waiting PDF files:

 

NG2AppendPDF0010

 

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:

 

NG2AppendPDF0011

(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:

 

NG2AppendPDF0012

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:

 

NG2AppendPDF0013

 

- and then save this PDF payload as a resource like it is done in the last sub-workflow:

 

NG2AppendPDF0014

 

The last workflow is described below:

 

The sub-workflow, Append1PDF

First the workflow loads the current PDF file to append into an attachment with the command, From file to attachment:

 

NG2AppendPDF0015

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:

 

NG2AppendPDF0016

 

Now the new PDF file can be appended with the component, Append a PDF:

 

NG2AppendPDF0017

(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:

 

NG2AppendPDF0018

(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:

 

NG2AppendPDF0019

 

With this the updated PDF file is available for the main workflow, where it can be attached to an email.