This section covers solutions of how you can use the page range of an input spooled file in order to only process a sub section of a spooled file specified on the PAGERANGE parameter as a from and to page number.
These scenarios are covered below:
1) Setup a template to only process pages within the specified page range.
2) Setup a spooled file split to only process pages with the specified page range.
When you map the contents of an input spooled file, then you will normally insert as repeat loop, that iterates across all of the pages in the input spooled file with the //page option as described here.
The input spooled file can however be limited in regards to a specific page range like shown below (where only page 17 to 27 are selected):
Work with Spooled File Attributes
Job . . . . . . . . : QPADEV0003 File . . . . . . . . : QPJOBLOG User . . . . . . . : KSE Number . . . . . . : 000001 Number . . . . . . : 875518 Creation date . . . : 08/06/23 Job system name . . : PMK250 Creation time . . . : 16:13:25
Page range to print: Starting page . . . . . . . . . . . : 17 Ending page . . . . . . . . . . . . : 27 |
This is setup on the PAGERANGE parameter on the spooled file.
The starting page and ending page can in the designer be found as the spooled file attributes://@startPage and //@endPage, so in the case above the //@startPage attribute contains the value 17 and //@endPage contains the value 27.
So we want the designer to limit a //page repeat loop to only run through the pages in the range 17 to 27. The current page number can be found with the Xpath function: position().
We can do that with this setup:
///page[position() >= //@startPage and position()<=//@endPage]
The expression inside [] limits the page (nodes) to only include the spooled file pages, where the expression inside is true. In the condition the condition is set, so that the expression is only true if the current page (found via the function: position() ) is larger or equal to the start page (of the page range) and less or equal to the end page.
If you want to combine the PAGERANGE parameter of the input spooled file with a split e.g. to generate multiple PDF files or emails from a single input spooled file, then you should follow the procedure below. The procedure first changes the payload containing the spooled file, so that it only contains the subset of pages before the spooled file split is executed.
This is possible with these workflow components:
1.Set multiple variables. Use this to setup a variable for both the start end end page number like so:
This extracts the spooled file attributes and copies the values into these variables for later reference.
2.Payload to named property. This is the first part of 'tricking' the workflow into processing the spooled file as an XML file. So here we first save the spooled file in the payload to a named property called backupData:
3.Named property to payload. Now we load the value back from the named property back into the payload and now we tell the workflow, that the payload is now an XML file like so:
4.XSL transformation. Now we can transform the XML file (which really contains the spooled file) with this function:
This refers to an XSL stylesheet, which should be defined as the source 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/" version="2.0"> <xsl:output indent="yes" method="xml"/> <xsl:param name="StartPage" /> <xsl:param name="EndPage" /> <xsl:template match="/"> <spool> <xsl:attribute name="copies"> <xsl:value-of select="/spool/@copies"/> </xsl:attribute> <xsl:attribute name="cpiChg"> <xsl:value-of select="/spool/@cpiChg"/> </xsl:attribute> <xsl:attribute name="created"> <xsl:value-of select="/spool/@created"/> </xsl:attribute> <xsl:attribute name="crtDate"> <xsl:value-of select="/spool/@crtDate"/> </xsl:attribute> <xsl:attribute name="crtTime"> <xsl:value-of select="/spool/@crtTime"/> </xsl:attribute> <xsl:attribute name="devFile"> <xsl:value-of select="/spool/@devFile"/> </xsl:attribute> <xsl:attribute name="devLib"> <xsl:value-of select="/spool/@devLib"/> </xsl:attribute> <xsl:attribute name="endPage"> <xsl:value-of select="/spool/@endPage"/> </xsl:attribute> <xsl:attribute name="formtype"> <xsl:value-of select="/spool/@formtype"/> </xsl:attribute> <xsl:attribute name="hldBfWrt"> <xsl:value-of select="/spool/@hldBfWrt"/> </xsl:attribute> <xsl:attribute name="jobName"> <xsl:value-of select="/spool/@jobName"/> </xsl:attribute> <xsl:attribute name="jobNbr"> <xsl:value-of select="/spool/@jobNbr"/> </xsl:attribute> <xsl:attribute name="outq"> <xsl:value-of select="/spool/@outq"/> </xsl:attribute> <xsl:attribute name="outqLib"> <xsl:value-of select="/spool/@outqLib"/> </xsl:attribute> <xsl:attribute name="pageLength"> <xsl:value-of select="/spool/@pageLength"/> </xsl:attribute> <xsl:attribute name="pageWidth"> <xsl:value-of select="/spool/@pageWidth"/> </xsl:attribute> <xsl:attribute name="pgm"> <xsl:value-of select="/spool/@pgm"/> </xsl:attribute> <xsl:attribute name="pgmLib"> <xsl:value-of select="/spool/@pgmLib"/> </xsl:attribute> <xsl:attribute name="savAftWrt"> <xsl:value-of select="/spool/@savAftWrt"/> </xsl:attribute> <xsl:attribute name="splf"> <xsl:value-of select="/spool/@splf"/> </xsl:attribute> <xsl:attribute name="splfNbr"> <xsl:value-of select="/spool/@splfNbr"/> </xsl:attribute> <xsl:attribute name="splfVersion"> <xsl:value-of select="/spool/@splfVersion"/> </xsl:attribute> <xsl:attribute name="srcDrwr"> <xsl:value-of select="/spool/@srcDrwr"/> </xsl:attribute> <xsl:attribute name="startPage"> <xsl:value-of select="/spool/@startPage"/> </xsl:attribute> <xsl:attribute name="system"> <xsl:value-of select="/spool/@system"/> </xsl:attribute> <xsl:attribute name="totalPages"> <xsl:value-of select="/spool/@totalPages"/> </xsl:attribute> <xsl:attribute name="user"> <xsl:value-of select="/spool/@user"/> </xsl:attribute> <xsl:attribute name="userData"> <xsl:value-of select="/spool/@userData"/> </xsl:attribute> <xsl:for-each select="//page[position() >= $StartPage and position() <= $EndPage]"> <xsl:copy-of select="."/> </xsl:for-each> </spool> </xsl:template> </xsl:stylesheet> |
In line 6 and 7 of this source the workflow variables are defined (which contains the start and end pages), and these variables are used in the expression in the bottom of the file to extract only the pages in this range.
5.Payload to named property. Now the payload is correct (it contains the right spooled file), but the workflow now expects the payload to be an XML file, so we now save the XML into the named property backupData like so:
6.Named property to payload. Now we can restore the payload back from the named property and in that process we can now 'tell' the workflow, that the payload restored from the named property is actually a spooled file like so:
7.Split spooled file.Now we can finally split the spooled file pages found in the selected page range e.g. like below (you need of course to select the line/positions to match your spooled file):