Spooled file multi-Up

Spooled file multi-Up

It is possible in InterFormNG2 to convert multiple input spooled file pages into a single output page. This is often referred to as either Multi-Up or pages per side.

 

A classic example of multi-up is this kind of output, where we have chosen to put 4 input pages into each output page:

 

NG2MultiUp0001

 

The multi-Up feature is however not limited to this kind of output.

 

The options for multi-up are covered in these sections:

 

1.Simple Multi-Up for spooled files

2.Convert input spooled file with transformations: Many into one.

 

 

Simple Multi-Up for spooled files

This section covers the scenario, where you want to map multiple input spooled file pages into a fewer number of output pages, where each page from the input spooled file has its own area.

For that we need to use the Grid layout option for the page element.

 

On the page element we decide how many pages/labels/areas we want on each output page. For details and prerequisites you should refer to the Grid layout. In this case we want to place 4 input pages on each output page.

 

That is setup as below on the grid layout settings on the page element:

 

NG2MultiUp0002

 

Inside the page element we insert a repeat for each page element of the input spooled file:

 

NG2MultiUp0003

 

For normal spooled file mapping we would insert the page element inside the repeat loop, but by setting up the template in this way we let InterFormNG2 decide when there is an overflow to a new output page. With the 2x2 grid layout and a container which fits 4 times within the output page we get the expected result:

 

NG2MultiUp0004

 

No gaps was defined for the grid layout, so there is room for this container 4 times on the page - even with a 6 mm margin. Please notice, that the container has a dynamic position.

 

Inside we have chosen to map some data from the current page of the input spooled file.

 

 

 

Convert input spooled file with transformations: Many into one

Instead of handling the multiple spooled file pages in their own area like above it is also possible to transform the spooled file before it is used in the template. Here you can even transform multiple input pages into fewer output pages in a new spooled file 'work file'. This simulates how this is done in InterForm400.

 

The requested transformation is like so: That the lines of multiple spooled file pages are merged into one and after the transformation the spooled file has fewer pages, but each page contains more lines.

 

Before we consider the transformation we first need to find out exactly how many lines there can be on an input spooled file page. That is found as an attribute of the spooled file, which you can e.g. see that after loading it into designer (or workflow) if you click the magnifying glass, the attributes tab and then pageLength as below:

 

NG2MultiUp0005

 

 

So in this case there are up to 66 lines on each page and we can now go ahead with the conversion. In this case we want to use multi-up=2, which means that the first 2 input pages should be converted into one. This can be extracted with this expression: //@pageLength.

 

The single output page will after the conversion have contents in this format:

The output page will contain up to 66*2=132 lines and they are:

 

Line 1 to 66 contains lines from page 1

Line 67 to 132 contains lines from page 2.

 

The conversion can be done in two steps:

 

First step: Add empty lines to each page to fill out the maximum 66 lines.

Second step: Merge the pages specified by Multi-Up.

 

First step: Add empty lines

This xsl transformation adds empty line nodes to ensure, that each page node always contains 66 lines:

 

 

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

                xmlns:ng="http://www.interform400.com/"

                exclude-result-prefixes="ng"

                version="2.0">

   <xsl:output indent="yes" method="xml"/>

   

   <!-- Identity template to copy all nodes and attributes -->

   <xsl:template match="@* | node()">

      <xsl:copy>

         <xsl:apply-templates select="@* | node()"/>

      </xsl:copy>

   </xsl:template>

 

   <!-- Template to add extra empty line nodes to each page -->

   <xsl:template match="page">

      <xsl:copy>

         <!-- Copy existing lines -->

         <xsl:apply-templates select="line"/>

         <!-- Add extra empty line nodes if necessary -->

         <xsl:variable name="remainingLines" select="66 - count(line)"/>

         <xsl:if test="$remainingLines &gt; 0">

            <xsl:for-each select="1 to $remainingLines">

               <line></line>

            </xsl:for-each>

         </xsl:if>

      </xsl:copy>

   </xsl:template>

</xsl:stylesheet>

 

 

Notice the '66' in bold, which match the page length.

 

So as first step we need to save the style sheet above (as a simple text file with extension .xsl) and install that in InterFormNG2 as a transformation. This will later be referred to in the workflow.

 

 

Second step: Merge page nodes

The second transformation is to merge multiple page nodes together and place the line nodes after each other.This can be done with a transformation like below:

 

 

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

                xmlns:ng="http://www.interform400.com/"

                exclude-result-prefixes="ng"

                version="2.0">

   <xsl:output indent="yes" method="xml"/>

   

   <!-- Parameter for the number of pages to merge -->

   <xsl:param name="MultiUp"/>

 

   <!-- Identity template to copy all nodes and attributes -->

   <xsl:template match="@* | node()">

      <xsl:copy>

         <xsl:apply-templates select="@* | node()"/>

      </xsl:copy>

   </xsl:template>

 

   <!-- Template to merge line nodes into fewer pages -->

   <xsl:template match="spool">

      <xsl:copy>

         <xsl:apply-templates select="@*"/>

         <!-- Group input pages into sets of $MultiUp -->

         <xsl:for-each-group select="page" group-adjacent="(position() - 1) idiv $MultiUp">

            <!-- Create a new merged page -->

            <page>

               <!-- Merge line nodes of grouped pages -->

               <xsl:for-each select="current-group()/line">

                  <xsl:copy-of select="."/>

               </xsl:for-each>

            </page>

         </xsl:for-each-group>

      </xsl:copy>

   </xsl:template>

</xsl:stylesheet>

 

 

This transformation is also to be saved as a text file and uploaded as a transformation in InterFormNG2. The variable, MultiUp is highlighted in bold above. This variable must be defined in the workflow prior to this transformation and in this variable we setup the number of pages, that should be merged.

 

The two transformation can now be used in a workflow below, where the input spooled file is transformed and saved as a file:

 

NG2MultiUp0006

 

If you then load the transformed spooled file into the Library you can then create a template based on this.

    • Related Articles

    • Spooled file support

      InterFormNG2 is able to process spooled files, if you install InterFormNG2 on the IBM i platform. Please notice, that spooled file support, as well as Spool2XML, are modules for InterFormNG2, that are purchased separately. You can also use the ...
    • Spooled file actions

      As a part of spooled file processing in InterFormNG2 on the IBM i platform, you might want to delete, hold or move the input spooled file to let the end user know, that the specific spooled file has been successfully processed. You can also change a ...
    • Save a spooled file

      You can save a spooled file with InterFormNG2 in three manners: 1.Save spooled file as InterFormNG2 document. 2.Save a spooled file without InterFormNG2 3.Save a spooled file into a save file with InterFormNG2 The third option is covered below. If ...
    • Spooled file into Excel

      This section shows how a spooled file can be converted into Excel. The example relates to a spooled file, that has a format like below: The spooled file is a multi-page spooled file with a header, some details lines (in the middle blue frame), which ...
    • Change spooled file mappings

      After you have mapped spooled file contents in either the designer or the workflow, then you might later want to change the mapping and e.g. select some other positions in the spooled file. This section describes a tip of how you can see the ...