Liezel Francisco
Liezel Francisco

Reputation: 45

Limiting lines per page in BI Publisher

I'm using RTF template to create a BI report. I need to limit the number of rows into 3 records on the 1st page only. The remaining records/rows will continue to fill the next pages. I'm also required to print the page total. I used the code below to limit the number of records, however it prints only 1 row. Any help will be appreciated. thanks

<?xdoxslt:set_variable($_XDOCTX, ‘counter’, 0)?>
<?xdoxslt:set_variable($_XDOCTX, ‘lines_page’, 3)?>
<?xdoxslt:set_variable($_XDOCTX, ‘tot_lines’, count(.//PdfDraftPurchaseOrderHeaderVORow))?> 
<?xdoxslt:set_variable($_XDOCTX,’remainder’,0)?>

<?for-each:PdfDraftPurchaseOrderHeaderVORow?>
<?xdoxslt:set_variable($_XDOCTX, ‘counter’, xdoxslt:get_variable($_XDOCTX, ‘counter’)+1)?>
<?if@row:xdoxslt:get_variable($_XDOCTX,’counter’) != xdoxslt:get_variable($_XDOCTX,’tot_lines’)?>
<?if@row:position() mod xdoxslt:get_variable($_XDOCTX, ‘lines_page’) = 0?><?call:breaking?><?end if?><?end if?>
<?end for-each?>

Upvotes: 2

Views: 11868

Answers (2)

bhuvan karuturi
bhuvan karuturi

Reputation: 331

you can use this syntax, if you want to break a page after n number of rows:

<? if position() mod 3 = 0?> 
<?split-by-page-break:?>
<?end if?>

this will break the page after 3 rows, then after 6 rows and so on for every 3 multiple. You can replace 3 with your desired row count.

By the way position() is the row number in your xml data source.


Upvotes: 1

EdHayes3
EdHayes3

Reputation: 1953

Try using this within the for-each

<?if: position() = 3?> 
<?split-by-page-break:?>
<?end if?> 

I made a simple example and this worked just fine. I got 3 records on the first page, and 6 on the rest.

As for page totals, add this after the element you want to sum, where TotalFieldName is the name of the total variable and Element is the XML number element you want to sum

<?add-page-total:TotalFieldName;Element?> 

Add this in the footer for the page total, where TotalFieldName is the variable we created above, and the NumberFormat is something like 9G999D00

<?show-page-total:TotalFieldName; 'NumberFormat'?>

Upvotes: 2

Related Questions