RTF number of pages Page x of y

rtf

Not sure if this is even possible but I am trying to save text via a plain text output to an RTF with special coding.

I have everything working except the total number of pages.

I want it to say "Page x of y", the bottom of each page to say "Page 1 of 3" for example, but I can't find the correct code for the total page number.

Some people said use \nofpages but the source says the use of \nofpagesN is the specify the number of pages in the document. Is there a formula or something I can use or maybe a way to put the last page number? Here is an example of my code, if you put it into an rtf file via notepad then save and open in wordpad or word you will see what I mean:

{\rtf1\pagestart1 {\header\brdrt\brdrth\ql\b Name:  \b0LAST, FIRST \par\b DOB:  \b0 1979/11/03 \par\b Service Date/Time:  \b0 2012/03/06 00:49:00 \par\b MRN:  \b0 XXXXXX \par\b Order Date/Time:  \b0 2012/03/05 01:14:00 \par\b Study ID:  \b0 } \par{\footer\pard\brdrt\brdrs\qc\fs16\b\ul CONFIDENTIALITY NOTICE \par\par\pard\brdrt\brdrs\keepn\ql\fs20 Date: \chdate\par\keepn\qc\fs20 Page \chpgn  of \nofpages\par}\b Study ID:  \b0 000000000000 \par\pard\brdrb\brdrth A bunch of text to make up more than one page. \par \par \par {\footnote\pard\b Some stuff in the footer \b0\par}}

Best Answer

Code:

This is page \chpgn  of {\field{\*\fldinst  NUMPAGES }}, wonderful!

produces output (fex.):

This is page 1 of 4, wonderful!

So, to create a footer in every page use something like:

{\footer\pard\qr Page \chpgn  of {\field{\*\fldinst  NUMPAGES }}\par}

(Remove \qr if you do not want to align the page numbering to the right.)

Related Topic