RTF number of pages Page x of y

rtf
Opy picture Opy · Mar 7, 2012 · Viewed 9.1k times · Source

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}}

Answer

Opy picture Opy · Mar 7, 2012

I got it. It was quite complicated and got a sample from a client that was already doing it. I figure it would be nice to post it here so at least the answer is now out on the NET.

Instead of this: Page \chpgn of \nofpages

I am using this:

{\insrsid2691151 Page }{\field{\*\fldinst {\insrsid2691151  PAGE }}{\fldrslt {\insrsid2691151 1}}}{\insrsid2691151  of }{\field{\*\fldinst {\insrsid2691151  NUMPAGES }}
{\fldrslt {\insrsid11226526 2}}}{\insrsid2691151 \par }}