How To Reset Page Numbering Between Document Sections in BI Publisher's Template Builder for Word

Under normal circumstances, it is fairly easy in Microsoft Word to reset page numbering when starting a new section of your document. However, such a simple thing can be non-trivial when dealing with the BI Publisher Template Builder plugin for Microsoft Office (available from Oracle โ€” see BI Publisher Desktop).

In short, doing this the normal way did not work for me, and in researching the issue I ran across a number of folks who were having the same problem. Page numbering was simply not being reset between sections, or worse, did not take into account a fluid document size based upon available data.

One suggestion I read said to wrap the page number cells in a BI Publisher repeating group using for-each@section, like so:

<?for-each@section:ID?> x/y <?end for-each?>

But this also didn’t work for me. Finally I had to edit the RTF file directly.

The RTF specification was of some help to me in doing this, as well as this explanatory page from Microsoft.

RTF files can be a little confusing, but most of the “junk” in the files is just special codes for formatting the text. I was able to find my way around easily enough by searching for labels or keywords from the document. By searching for the first few words from the second section of the document (in this case, “Sender’s Receipt”), I was able to spot where the section break should go.

Checking the RTF spec, I could see that the \page directive shown above was the page break between two sections of my document where I wanted to reset the page numbering. To create the section break, I inserted the following RTF directives at that point:

\sect \sectd \pgnstarts1\pgnrestart

Since the default behavior of the section break is to start on a new page, I found I had to remove the \page directive to avoid an extra page being inserted between the document sections.

Interestingly, resetting the page numbering also works when calculating total number of pages, whereby the total is from the section, not the entire document, even though the NumPages field is used instead of SectionPages! Go figure, but it worked for me.

comments powered by Disqus