Skip to main content
Skip table of contents

XML2PDF

This component creates PDF files using XML and XSL Style sheet (or XSL-FO) as input. It uses the Apache FOP library to create PDF files.

Configuration and Testing

Properties can be configured in the Configuration Property Sheet (CPS) of the component. The properties available are explained below.

Component Configuration


Figure 1: Component Configuration panel

Attributes

XML2PDF Configuration

Input and Output details of XML2PDF transformation have to be provided here. Click the ellipsis 

button against this property to configure the same in the dialog box.


Figure 2: XML2PDF Configuration dialog box

Create PDF Using

The input to the component can be configured here. The component accepts data in 2 formats as follows:

  • XML and XSL
    The path of the XSL style sheet has to be specified in the Custom Property Sheet and XML data has to be sent as an input to the component through its input port
  • XSL-FO
    XSL-FO has to be sent as an input to the component through its input port.

Create PDF Using XML and XSL

XSL File Path

The path of the XSL Style Sheet has to be specified here. This property has a file filter and only the files with the .xsl extension will be shown in the file chooser.

This property is available only when the input type is selected as "XML and XSL".

Output Directory

The output directory in which PDF files have to be generated should be specified here.

Output File Name

The name for the output file that has to be created. By default, this name is used for the output file. If a different file name has to be used, then a JMS Property "filename" has to be set on the input message to the component.

User Configuration file

File containing custom configuration.

Named Configuration

A specific configuration can be configured as Named Configuration to use it across multiple instances.

Please refer to Save Named Configuration section in the Common Configurations page to know how to save a named configuration.

Error Handling Configuration

The remedial actions to be taken when a particular error occurs can be configured here.

Click the ellipsis 

button against this property to configure Error Handling properties for different types of Errors.

Please refer Error Handling section in Common Configurations page for detailed information.

Expert Properties

Enable the Expert Properties view to configure these properties.

Expert properties are meant for advanced users.


Figure 3: XML2PDF CPS with the Expert Properties enabled and highlighted

Pre Processing XSL Configuration

Pre Processing XSL configuration can be used to transform request message before processing it. Click the ellipses button against the property to configure the properties.

Refer to the Pre/Post Processing XSL Configuration section under the Common Configurations page for details regarding Pre Processing XSL configuration and Post Processing XSL configuration (below).

Post Processing XSL Configuration 

Post Processing XSL configuration can be used to transform the response message before sending it to the output port.

Process Message Based on Property

The property helps components to skip certain messages from processing.

Refer to the Process Message Based On a Property section under the Common Configurations page 

Xslt Engine

Specify the transformer implementation that is used for performing the transformation.

Xalan (2.7.0) and Saxon (8.4) transformer implementations are bundled with Fiorano environment for performing transformations:

  • Xalan
    Xalan implementation (org.apache.xalan.processor.TransformerFactoryImpl) is used to perform transformation.

    Xalan(2.7.0) does not support XSLT 2.0.

  • Saxon
    Saxon implementation (net.sf.saxon.TransformerFactoryImpl) is used to perform transformation.

    Saxon implementation does not support custom functions.

Threadpool Configuration

 This property is used when there is a need to process messages in parallel within the component, still maintaining the sequence from the external perspective. 

Refer to the Threadpool Configuration section under the Common Configurations page.

Functional Demonstration

XML and XSL

Configure XML2PDF component to use XML and XSL as input type as explained in Configuration and Testing section.

Launch the flow and send the sample XML input through Feeder component.

If the PDF creation is successful, the component sends an XML message which contains OutputDirectory, OutputFile and Message elements on to its output.
If there is any error in generating the PDF file, an error message indicating the exceptions will be sent to the component's ON_EXCEPTION port.


Figure 4: Sample Event Process

Sample Input

XSL Style Sheet

XML
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                version="1.0">

  <xsl:template match="/">
    <fo:root>
      <fo:layout-master-set>
        <fo:simple-page-master master-name="my-page">
          <fo:region-body margin="1cm"/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      
      <fo:page-sequence master-reference="my-page">
        <fo:flow flow-name="xsl-region-body">
          <xsl:apply-templates/>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template>
  
  <xsl:template match="FX">
    <fo:block background-color="#00b2e6" font-weight="bold" space-after="10pt">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  
  <xsl:template match="speech[@speaker = 'Def']">
    <fo:block background-color="#00b2e6"  space-after="10pt">
      <xsl:value-of select="@speaker"/>:
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  
  <xsl:template match="speech">
    <fo:block space-after="10pt">
      <xsl:value-of select="@speaker"/>:
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  
</xsl:stylesheet>

XML

XML
<scene>
  <FX>XML 2 PDF Test</FX>
  <speech speaker="Abc">
    Test Test Test 123.
    Test Test Test 123
    Test Test Test 123
  </speech>
  <speech speaker="Def">
    456 456 456
        456 456 456
            456 456 456
                456 456 456
  </speech>
</scene>

Output


Figure 5: Output generated in the Display window in XML format


Figure 6: Output PDF File

XSL-FO

Configure XML2PDF to use XSL-FO as input type. Launch the flow and send the sample XSL-FO input through Feeder component. Also use a different output file name by setting filename JMS property on the Input message.

If the PDF creation is successful, the component sends an XML output message which contains OutputDirectory, OutputFile and Message elements on to its output as shown below.
If there is any error in generating the PDF file, an error message indicating the exceptions will be sent to the component's ON_EXCEPTION port.

Sample Input

XSL-FO

XML
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
 <fo:layout-master-set>
  <fo:simple-page-master master-name="content" margin="0.5in">
   <fo:region-body region-name="body" margin-top="0.5in" 
    column-count="2"/>
   <fo:region-before region-name="header" extent="0.25in"/>
  </fo:simple-page-master>
 </fo:layout-master-set>
 <fo:page-sequence master-reference="content">
  <fo:static-content flow-name="header">
   <fo:block border-bottom-width="1px" border-bottom-style="solid" 
    text-align="end">FIORANO</fo:block>
  </fo:static-content>
  <fo:flow flow-name="body">
   <fo:block span="all" font-size="14pt" font-weight="bold" 
    text-align="center" padding-before="16pt">
    I. HEADING 1
   </fo:block>
   <fo:block space-before="8pt">
    This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. 
    This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. 
   </fo:block>
   <fo:block span="all" font-size="14pt" font-weight="bold" 
    text-align="center" padding-before="16pt">
    II. HEADING 2
   </fo:block>
   <fo:block space-before="8pt">
    This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. 
   </fo:block>
   <fo:block space-before="8pt">
    This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. 
   </fo:block>
   <fo:block span="all" font-size="14pt" font-weight="bold" 
    text-align="center" padding-before="16pt">
    III. HEADING 3
   </fo:block>
  </fo:flow>
 </fo:page-sequence>
</fo:root>
Output

Figure 6: Output generated in the Display window in XML format


Figure 7: Output PDF File


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.