Implementing PDF Splitting for an RTF Template

This section describes how to enable PDF splitting for reports generated from RTF templates.

This section includes the following topics:

Entering the Commands in an RTF Template

When you design a template to use this feature, you must add commands to specify these queries.

  • What element in the data is repeated (using the simple for-each command)

  • How many occurrences of the element are included in each PDF file

  • What information (data elements) to include in the index file

To achieve this, the following two commands must be entered in the template within the for-each loop of the element by which you want the document to split:

  • <?catalog-index-info:name;element_name?>

    where

    name is the name that you choose that is used in the index file to identify the from and to records included in each document.

    element_name is the XML tag name of the element that provides the value for name that you identify above.

    The catalog-index-info command defines the construction of the index file that is created.

  • <?if:position() mod n = 0?><?document-split:?><?end if?>

    where

    n is the number of records you want included per PDF file.

    This command must be placed within the for-each loop of the element that is to be counted. This command instructs BI Publisher to split the document after the next page break when the number of records equals the value you have supplied for n.

    Each time the document-split is performed, the name-value pairs defined in the catalog-index-info command are written to the index files.

Example - split by each department

This example is based on the XML data given here.

This example is based on the following XML data:

<DATA_DS>
 <G_EMP>
  <DEPARTMENT_NAME>Sales</DEPARTMENT_NAME> 
  <FIRST_NAME>Ellen</FIRST_NAME> 
  <LAST_NAME>Abel</LAST_NAME> 
  <HIRE_DATE>1996-05-11T00:00:00.000-07:00</HIRE_DATE> 
  <SALARY>11000</SALARY> 
 </G_EMP>
 <G_EMP>
  <DEPARTMENT_NAME>Sales</DEPARTMENT_NAME> 
  <FIRST_NAME>Sundar</FIRST_NAME> 
  <LAST_NAME>Ande</LAST_NAME> 
  <HIRE_DATE>2000-03-24T00:00:00.000-08:00</HIRE_DATE> 
  <SALARY>6400</SALARY> 
 </G_EMP>
 <G_EMP>
  <DEPARTMENT_NAME>Shipping</DEPARTMENT_NAME> 
  <FIRST_NAME>Mozhe</FIRST_NAME> 
  <LAST_NAME>Atkinson</LAST_NAME> 
  <HIRE_DATE>1997-10-30T00:00:00.000-08:00</HIRE_DATE> 
  <SALARY>2800</SALARY> 
 </G_EMP>
 <G_EMP>
  <DEPARTMENT_NAME>IT</DEPARTMENT_NAME> 
  <FIRST_NAME>David</FIRST_NAME> 
  <LAST_NAME>Austin</LAST_NAME> 
  <HIRE_DATE>1997-06-25T00:00:00.000-07:00</HIRE_DATE> 
  <SALARY>4800</SALARY> 
 </G_EMP>

...
</DATA_DS>

In this example, the output PDF report includes a document for each employee. You want a new PDF file generated for each department. You want the index to list the FIRST_NAME and LAST_NAME from each record that is included in the PDF file.

To achieve this output, enter the following in the template:

<?for-each-group:ROW;./DEPARTMENT_NAME?>
<?for-each:current-group()?>
<?catalog-index-info:'First Name';FIRST_NAME?>
<?catalog-index-info:'Last Name';LAST_NAME?>
...
<?end for-each?>
<?document-split:?>
<?end for-each-group?>