Tuesday 24 December 2013

Displaying Page Totals in XML Publisher

XML Publisher allows you to display calculated page totals in your report. Because the page is not created until publishing time, the totaling function must be executed by the formatting engine.
Note: Page totaling is performed in the PDF-formatting layer. Therefore this feature is not available for other outputs types: HTML, RTF, Excel. Because the page total field does not exist in the XML input data, you must define a variable to hold the value. When you define the variable, you associate it with the element from the XML file that is to be totaled for the page. Once you define total fields, you can also perform additional functions on the data in those fields. To declare the variable that is to hold your page total, insert the following syntax immediately following the placeholder for the element that is to be totaled:
<?add-page-total:TotalFieldName;’element’?>
where TotalFieldName is the name you assign to your total (to reference later) and
’element’ is the XML element field to be totaled. You can add this syntax to as many fields as you want to total. Then when you want to display the total field, enter the following syntax:
<?show-page-total:TotalFieldName;’number-format’?>
where TotalFieldName is the name you assigned to give the page total field above and
number-format is the format you wish to use to for the display. The following example shows how to set up page total fields in a template to display total credits and debits that have displayed on the page, and then calculate the net of the two fields.
Here we are going to take same RTF which is shown below
This example uses the following XML:
Now we are going to take one field in Inv_Amt which is shown below
Give double click on the field and Provide proper default text and in Add Help Text and in that we are going to write below command
<?add-page-total:pagetot;’INVOICE_AMOUNT’?>
Which is shown below
Now we have to display this pagetot(total field name) by using below syntax: -
<?show-page-total:TotalFieldName;’number-format’?>
Example: -<?show-page-total:pagetot;’999G999D99’?>
For that we have to place one form field which is shown below
Provide proper default text and in Add Help Text we are going to write below code which is shown below
<?show-page-total:pagetot;’999G999D99’?>
Now our RTF looks

Now we have to publish the report

Click on Template Builder => Preview => HTML/PDF/Excel/RTF (any format).
We can get below output
From the above output we can see that page total. If there is two or more pages then we can see page total for every page.

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Can you help me calculating total of price of items in a bill. I have a field 'Price' (quantity*list price)in RTF. what can i do to get 'Total Price'. I done have an xml element in 'Total Price' to get subtotal.

    ReplyDelete
  3. Could not able to display the show-page-total value.
    Could you please help

    ReplyDelete