RTF number of pages Page x of y

Not sure if this is possible, but I'm trying to save text through text output in RTF with special encoding.

Everything works for me, except for the total number of pages.

I want him to say “Page x of y,” at the bottom of each page, for example, “Page 1 of 3,” but I cannot find the correct code for the general page number.

Some say they use \nofpages , but the source says that using \nofpagesN is to indicate the number of pages in a document. Is there a formula or something that I can use, or perhaps a way to put the last page number? Here is an example of my code, if you put it in an rtf file via notepad, then save and open in a text box 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}}
+4
source share
3 answers

I understood. It was quite complicated and got a sample from a client who was already doing this. I suppose it would be nice to post it here, so at least now the answer is on NET.

Instead: Page \ chpgn of \ nofpages

I use this:

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

the 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 on each page, use something like:

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

(Delete \qr if you do not want to align the pagination to the right.)

+2
source

For those who still have problems with previous solutions, here is another way to generate “Page x of y” as a footer for all pages.

 {\rtf1\ansi\deff0 {\footer\qr{ Page {\field{\*\fldinst {PAGE}}{\fldrslt {Refresh >F9<}}} of {\field{\*\fldinst {SECTIONPAGES}}{\fldrslt {Refresh >F9<}}} }\par} {{Hello, RTF!}\par} } 

Please note that for some reason, some RTF viewers may not properly refresh the current page or page count of a document. The above code ensures that these fields are updated.

+2
source

Source: https://habr.com/ru/post/1400222/


All Articles