I promised a 'how-to' get Terms and Conditions onto your outputs - to be more specific to get them on the back of every page of a document e.g. an Invoice that looks like the following.

Notice that the physical pages 1 and 3 are the invoice and 2 and 4 are the terms and conditions. For the logical pages thou, the terms and conditions are not part of total number of pages calculation i.e. there are only 2 pages in the document. Once the document is printed in duplex there are in fact only 2 physical pages.
Also notice that even thou there are 2 invoice pages we need T&Cs on the back of every page - so even thou the document would normally finish on the second invoice page we are forcing the rendering engine to eject that last page with the TandCs on it.
We can achieve this with a little effort and some new commands in the RTF to suppress numbering and to end on an even page.
We start with a regular template, lets work with something new, a Sales Order template. Running that against the SO data set gets us sales orders with page numbers and headers resetting as expected with the /@section command.
Now, we need to introduce the Terms and conditions page - to get this we insert a section break into the template after the end of the invoice template. Then we go to the File > Page Setup dialog

and set the document to have different Odd and Even headers and footers.
To get the T&Cs into the new page we need to use the sub-templating approach. Sounds bad, but its not - its actually a bonus. How many of your docs need T&Cs? How many of those share the T&C content? Im asking cos I dont know - never look at them on the invoices I receive - I just buy stuff in blind faith me. Anyhoo, even if each doc has a different set of T&C content you can still put it all in the same sub template file and only need to update it in one place to affect all dependent docs - neat!
We have an import statement to pull in the T&C template:
<?import:tcs.rtf?>
there are some things to point out here. If you are testing using the Template Builder for Word you can not call the 'rtf directly. Create your T&Cs template in Word like this one - then use the Tools > Export > XSL-FO Stylesheet and save this as your template. Then modify your import statement to pull in the xsl version of the template.
Of course when you deploy to the server you can use the xdo:// URI for EBS or other URIs for the specfic version you are on.
Inside the TC template file we have a template that simply holds the T&Cs text -
<?template:TC?>
Lorem ipsum ....
<?end template?>
In the main template we then have:

A section break and then in the header of the next page a call to the TC template.
Now all we need are the new commands to get this to work:
<?section:force-page-count;'end-on-even-layout'?>- this forces the rendering engine to end on an 'even' page i.e. tack on a T&C page after the last page of the sales order. You can of course finish on an odd page if you wish.
<?section:xdofo:blank-on;'even-skip-page-count'?>
- this handles the supression of the T&Cs pages from the total number of pages.
You'll notice that my examples are ejecting an extra page for each sales order - thats a bug and its been fixed - check patch#:6416280
All files available here and the pertinent bits in the template highlighted in red.
Comments (2)
Our TC for PO is designed to be on the last page of all documents making it what I thought was simpler than this example since no pagination issues here. I have used this code example except for the "Tools > Export > XSL-FO Stylesheet" part and I can view it here in my Template Builder for Word with the Preview PDF I can see the results when I import: . That works great!, I need to have it in two newspaper columns though so I threw a section break continuous in. That too looks great, I am getting a page break side effect, however, coming back out of the section break block and it is a little frustrating. To remedy that I tried the XSL-FO Style sheet idea; seems to be the right thing to do. Both your example and my work error: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at oracle.apps.xdo.common.xml.XSLT10gR1.invokeNewXSLStylesheet(XSLT10gR1.java:520)
at oracle.apps.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:196)
at oracle.apps.xdo.common.xml.XSLTWrapper.transform(XSLTWrapper.java:161)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:1015)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:968)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:209)
at oracle.apps.xdo.template.FOProcessor.createFO(FOProcessor.java:1561)
at oracle.apps.xdo.template.FOProcessor.generate(FOProcessor.java:951)
at RTF2PDF.runRTFto(RTF2PDF.java:626)
at RTF2PDF.runXDO(RTF2PDF.java:460)
at RTF2PDF.main(RTF2PDF.java:251)
Caused by: java.util.EmptyStackException
at oracle.xdo.parser.v2.XSLProcessor.reportException(XSLProcessor.java:782)
at oracle.xdo.parser.v2.XSLProcessor.newXSLStylesheet(XSLProcessor.java:564)
...
HELP!
Posted by Gary McFarling | July 15, 2008 12:29 PM
Posted on July 15, 2008 12:29
Hi Tim,
thanks for this post its really great;
but we got a blank page at the end of the output file.
also the sample one attached here in this note have this blank page ; any solution ?
thanks in advance
Posted by Ahmed Sabry | August 18, 2008 2:07 AM
Posted on August 18, 2008 02:07