Please enable JavaScript to view this site.

InterFormNG2 Manual

It is possible to output the pages of a spooled file in reverse order. This section describes how you can setup a template in InterFormNG2 to achieve that.

 

That is possible, if you setup a template like below:

 

NG2SplfReverseOrder0001

 

Each of the steps are explained below:

 

1. Variable PageCounter is set to the attribute, endPage. This is the last page of the spooled file. We intend to use the variable PageCounter to count backwards, so that is what the initial value is the last page number. We refer to the attribute, endPage as a way to only process the pages within the pagerange of the spooled file. We will use this as an index to the current page number.

 

2. A repeat is defined. This is the number of pages, that we will go through. Again this respects the pagerange so we refer to the first page of the original spooled file via the attribute, //startPage. So the number of page is the last page number minus the first page number plus 1.

 

3. A current page repeat is defined as "/spool/page[number($PageCounter)]". This is used as a way to set a current page of the spooled file. Any reference to the spooled file contents as a reference to the current page (Auto) will automatically refer to the current page in this reverse loop. The path /spool/page refers to the page nodes in the internal XML file, that actually contains the spooled file. The [] enables us to set a specific page number as index and select the current page. We need to refer to the PageCounter as a number, so we use the number() function to force/cast the PageCounter into a number.

 

4. A page element is the container in which we can setup the actual design of the output pages.

 

5. A text element. Inside the page element we here insert a text element, that maps spooled file data from the current page in the normal way.

 

6. Decrease the PageCounter variable. We decrease the PageCounter with 1 with the expression: $PageCounter - 1. Please note, that you need to insert a space prior to the minus sign in order to separate it from the previous variable name.

 

 

Combining reverse order with new page breaks

It is also possible combine this reverse order with the option to change page breaks of an input spooled file. In such a case you will probably want to divide the output in a header, footer and body section, to reuse the same header in the output. Below is an example which shows how that can be done:

 

NG2SplfReverseOrder0002

 

There are a few changes compared to the previous example:

 

The header and footer elements has been added as a way to reuse the same header/footers on all the pages.

A remap of the spooled file data from page 1 is added in the header.

A footer is added with a container to ensure that detail lines are not getting too close to the edge.

A line repeat is added (subsequence(./line, 30, 13) to iterate over the detail lines of each page.This repeats over 13 lines starting in line 30.

Inside the line repeat the data of the current line is output in the text element: ng:spoolMapRel(., 1, 75, 0, 1). This remaps position 1 to 75 of the current detail line of the repeat loop.

 

With the settings above the output below is created for a demo spooled file. The bold text is the header data and the detail lines are output in reverse order - last page first:

 

NG2SplfReverseOrder0003