BI Publisher中如何通过限制表格每页行数实现空白支票打印?
Hey there, let's walk through how to build this RTF template for your void checks requirement in BI Publisher. I’ve worked on similar check printing workflows before, so here’s a practical, step-by-step breakdown that aligns with your rules:
First, Let’s Confirm the Requirements
- Every page must include both an invoice detail table and a check section.
- If your invoice count exceeds 38:
- The first page will display exactly 38 invoices in the table.
- Below that table, print a void check showing the total amount of those 38 invoices.
- Carry over remaining invoices to the next page, repeating the same rule.
- For the final page (with fewer than 38 invoices), the check will be your regular non-void version (adjust the condition if you need it void too).
Step 1: Set Up the Base RTF Template
Start with a blank Word document and set page dimensions to match your physical check stock (this is critical for proper alignment later). Then define two core sections:
- Invoice Detail Table: For listing invoice numbers, amounts, and other relevant details.
- Check Section: Design your check layout here—include fields for payee, amount, date, and space for the "VOID" watermark.
Step 2: Group Invoices into Chunks of 38
Use BI Publisher’s for-each-group function to split your invoice data into groups of max 38. Insert this tag right before your invoice table:
<?for-each-group:INVOICE;ceil(position() div 38)?>
Replace INVOICE with your actual data group name from your XML source. This will automatically group invoices into blocks of 38 (or fewer for the final group).
Step 3: Build the Invoice Table & Calculate Group Total
Inside the group tag, create your invoice table. For each row, pull in invoice details using BI Publisher fields (e.g., <?INVOICE_NUMBER?>, <?INVOICE_AMOUNT?>).
Add a total row at the bottom of the table to sum the amounts for the current group:
Total: <?sum(current-group()/INVOICE_AMOUNT)?>
This dynamically calculates the total for the 38 (or fewer) invoices on the page.
Step 4: Ensure Table & Check Stay on the Same Page
To prevent the table from splitting across pages and keep the check paired with its invoice table:
- Select the entire block (invoice table + check section).
- Right-click > Paragraph > Go to the Line and Page Breaks tab.
- Check both Keep lines together and Keep with next.
This forces Word (and BI Publisher) to keep the entire block on one page.
Step 5: Add Void Check Logic
In your check section, show the "VOID" text/watermark only if there are more invoices after the current group:
<?if:position() != last()?> <!-- Insert your VOID text or watermark here --> <textbox style="font-size:72pt; color:#cccccc; text-align:center;">VOID</textbox> <?end if?>
For the amount field on the check, use the same group total we calculated earlier: <?sum(current-group()/INVOICE_AMOUNT)?>. For currency formatting, use:
<?format-number(sum(current-group()/INVOICE_AMOUNT), '$#,##0.00')?>
Step 6: Add Page Breaks Between Groups
After each check section, insert a page break to start the next group of invoices on a new page:
<?split-by-page-break:?>
Place this tag right after the closing <?end for-each-group?> tag (or immediately after the check section).
Step 7: Test & Tweak
- Use BI Publisher’s Template Builder for Word to preview your template with sample XML data. Test with 38, 39, and 76 invoices to verify:
- Groups split correctly.
- Totals are accurate.
- Void checks appear only on pages with 38 invoices (and more remaining).
- The table and check stay paired on the same page.
- Adjust margins, check positioning, and font sizes to match your physical check stock—this may take a few iterations to get perfect.
Quick Pro Tips
- For the VOID watermark, use a semi-transparent light gray color so it’s visible but doesn’t obscure check details.
- Ensure your XML data is properly structured with all required fields (invoice number, amount, etc.) for grouping and totaling.
内容的提问来源于stack exchange,提问作者Bhavna

