In the section below you can see how you can setup the workflow in InterFormNG2 to create a PDF file and insert it into the input XML file encoded in base64.
The complete workflow looks like below:
First part:
Second part:
Each of the component are described below in these 8 sections:
1.Reads an input XML file from a folder.
2.Stores the input XML file in a property named backupData.
3.Creates a PDF document and overwrites the XML in the payload with the PDF, that is the result of this merge.
4.The data of the PDF file is converted into base64 and the base64 data stream now replace the PDF in the payload.
5.The base64 payload is copied into a workflow variable named Base64.
6.The input XML file is retrieved into the payload again from the named property, backupData, which was saved in step 2.
7.The base64 data in variable Base64 is inserted into the input XML file via an xslt transformation.
8.The transformed XML file with the base64 data is saved to the file system.
This is defined via a new workflow with the read from file as input. In this example it looks like this:
In this example we monitor the folder inbox_insert_base64 in the InterFormNG2 home directory.
We keep a copy of the input file in a named property with the workflow component, payload to named property. In this case we use this setup:
We use the Create PDF document component to create a PDF by merging the input XML with a template:
The PDF data stream is converted into base64 with the component, To base64, which has no parameters.
The base64 payload is copied into a workflow variable, Base64 via the Payload to workflow variable component with this setting:
With the named property to payload component we can reload the input XML file into the payload like so:
The variable, Base64 contains the base64 datastream and that is inserted with the XSL transformation component, that in this case refers to a transformation file:
The contents of the xslt file is this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:param name="Base64" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/Root/CompanyInfo">
<xsl:copy>
<xsl:copy-of select="node()"/>
<PDF_Base64><xsl:value-of select="$Base64" /></PDF_Base64>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
This xslt defines the variable, Base64 and inserts the value into a new node named, PDF_Base64 in the path, /Root/CompanyInfo.
Finally the changed XML file is saved with the To filesystem component: