X

An Oracle blog about BI Publisher

  • RTF
    October 10, 2007

Here are my Terms & Conditions

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.


TC1:


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


TC2:


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:


TC3:


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 suppression 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.



Join the discussion

Comments ( 15 )
  • Gary McFarling Tuesday, July 15, 2008
    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!
  • Ahmed Sabry Monday, August 18, 2008
    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
  • SAI Sunday, February 22, 2009
    I have a business requirement to print payment options on the back of the FIRST page of the invoice.Your blog is very informative about printing T&C on the back of each page of invoice and I was trying to get leads for my requirement. But that did not help me specifically in my case - because I need payment options ONLY on the FIRST page of the invoice.
    1. Is this possible using XMLP?
    2. How do I do it ?
    We are on R12 Oracle E-Business Suite.
  • Rownald Membrere Wednesday, March 11, 2009
    Hi Tim,
    May I know where to find references for "new" available XML/BI Publisher commands? I'm doing a PO template with similar requirement with your blog (except that T&C should be printed only at the back of last page) - and still incomplete :(. The T&C page is still being counted as part of the total pages, not physically printing at the back of last page.
    I was hoping to have some commands similar(i.e. even-skip-page-count) to the above but specific on handling first/last page.
    Any help on how to use the above commands with the "last page only" command? Thanks in advance!
  • Praveen Monday, March 30, 2009
    Thanks Tim...it was really useful to me.
    I am still facing an issue when am trying to print multiple invoices (for a range of invoice).
    The issue is the XML engine still renders an extra page when printing multiple invoices(using COMBINE USE OF BLANK-ON AND FORCE-PAGE-COUNT RENDER EXTRA PAGE
    ) after applying patch#:6416280 wherehas it works fine when printing for an Invoice.
    Kinldy let me know if am missing something / if you've faced similar issue.
  • Michael Vourakis Friday, July 3, 2009
    Hi Tim,
    Very helpful code-method
    May I ask you : I would like to print a report on odd pages only and at the end of the report to print T&C on every page, ie how can I disable the skip-even-pages after a point and print on every page after that point ?
  • Hok Min Lie Wednesday, July 8, 2009
    [ANSWERS]
    1) For the EmptyStackException, the fix is to get the latest patch for xdoparser.jar.
    2) The blank page in the output can be fixed by removing the page-break that separate the first page from the second page. Doing so will make changing of the RTF template harder because we don't see the even-page-layout. So, do this only at the very last step.
    3) Payment option in the first page can be accomplished simply by inserting the payment option table at the end of the first page.
  • SS Thursday, August 6, 2009
    Hi Michael Vourakis,
    I am looking at exactly what you want,Have you got a solution for this,if yes can you please post it here.
    Thanks
  • Joon Wednesday, October 21, 2009
    Hi,
    How can I get rid of extra pages in the end when using this solution? I'm using R12. Please advise.
  • Rinki Goel Thursday, September 16, 2010
    Hi Tim,
    Thanks for "Terms and Conditions" post its really helpfull. The only issue is the bug which you have already stated in the post i..e "" expression ejects an extra page .
    I have applied the patch# 6416280 which you have suggested in the post, but for some reason its not helping in supression of extra page.
    Please let me know what I m missing?
    Regards, Rinki
  • Kevin Thursday, August 18, 2011

    Any chance of adding the missing screenshots and files?

    The link has expired.


  • Greg Tuesday, March 13, 2012

    Hi Tim,

    This is great for static text for the "Terms and Conditions". Would you please give some example or hints hoe to do data driven text on the back. I need to do self-sealed checks with the mailing address on the back (duplex printing).

    Thanks in advance,

    -- Greg


  • guest Tuesday, March 13, 2012

    Any possability to do dynamic data driven text on the other side (Duplex printing) ? (Mailing address for the check receipient).

    Thanks,

    -- Greg


  • Tim Wednesday, March 14, 2012

    Hi Greg

    Not sure that you really need this level of functionality. If you are printing duplex just have a second page in your template to handle the address (this assumes you will only fill a single page of course.)

    If you will perhaps have more than a single page of main data then you should look at the odd/even page functionality in the user docs.

    Regards

    Tim


  • guest Wednesday, September 19, 2012

    Hi Tim,

    We have a similar scenario but the actual template has 2 pages. The template is for printing Invoices and the report can run into 2 pages depending on the number of lines.

    The requirement is to print the Bill to Address on the back of the first page only.

    We modified the template to include another page (as the first one) with the Bill to Details and then introduced a page break for the numbering to start from the actual data sheet. On generating the PDF, the report looks good.

    The issue we have is, when we print the pdf on both sides. We need to insert a blank page every time, the report extends to a second sheet.

    Is there a way to insert blank pages at runtime(if the data generated is on more than 1 page) without affecting the page numbering?

    Page 1 - Bill to address

    Page 2 - template( Invoice hdr, line)

    Page 3 - if number of lines are more, the Invoice line can run to multple pages

    Required End result: Bill to address at the back of the first page of invoice


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.