Having looked at the various options on the forum I have chosen to go with ...
DBRichViewEdit1SaveRTFExtra
RTFCode :=
'{\header\pard\plain\posxc Header text goes here \par}'+
'{\footer\pard\qr © ABCWXYZ Pty Ltd Page \chpgn of {\field{\*\fldinst NUMPAGES }}\par}';
This works OK but I have several questions about the saved document.
1/ How do I stop the header and footer appearing on page one?
2/ How do I set the format/style of the header/footer ie font, font size etc
3/ How do I set the height allocated for the header / footer?
Saving RTF with headers and footers including page numbering
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
1. Add \titlepg
If \titlepg is added, you can specify special header and footer for the first page in {\headerf ...}{\footerf ...}
2. Please google for "RTF specification"
For example, \b made the subsequent text bold, \fs20 sets its size to 10pt (a parameter is in half-points).
The problem is in colors and font names. They are written as indexes in special tables, and you do not have access to these tables in this event
3. You can define the top of header and the bottom of footer: \headeryN and \footerYN, where N - size in twips (1 twip = 1/20 pt = 1/1440 inch)
Note1: \titlepg, \headery, \footery must be placed outside of {\header ...}{\footer ...}
Note2: You can define headers and footers in separate RichViews; page number field will be implemented in TRichView soon, in this month
If \titlepg is added, you can specify special header and footer for the first page in {\headerf ...}{\footerf ...}
2. Please google for "RTF specification"
For example, \b made the subsequent text bold, \fs20 sets its size to 10pt (a parameter is in half-points).
The problem is in colors and font names. They are written as indexes in special tables, and you do not have access to these tables in this event
3. You can define the top of header and the bottom of footer: \headeryN and \footerYN, where N - size in twips (1 twip = 1/20 pt = 1/1440 inch)
Note1: \titlepg, \headery, \footery must be placed outside of {\header ...}{\footer ...}
Note2: You can define headers and footers in separate RichViews; page number field will be implemented in TRichView soon, in this month
Saving RTF with header and footer
Sergey thank you for your swift and comprehensive response.
Following your advice I have a usable solution but I am most interested in the update you mention.
I found a very useful reference site http://latex2rtf.sourceforge.net/rtfspec_7.html
For others interested my final code is ...
procedure TForm3.RichViewEdit1SaveRTFExtra(...
RTFCode :=
'\margl1150\margr1150\margt1438\margb1150'+
'{\header\pard\plain\posxc\fs23 Header text goes here\par}'+
'{\footer {\pard \brdrb \brdrs\brdrw10\brsp20 {\fs4\~}\par \pard} \pard\plain\qc\fs23 Footer text goes here Page \chpgn of {\field{\*\fldinst NUMPAGES }}\par}'+
'\titlepg'+
'{\headerf\pard\plain\posxc\fs23 First page Header\par}'+
'{\footerf {\pard \brdrb \brdrs\brdrw10\brsp20 {\fs4\~}\par \pard} \pard\plain\qc\fs23 First page Footer\par}'+
'\headery800'+
'\footery800';
This sets margins left,right,top and bottom
Sets a default header and footer (with page numbering) plus a separate first page header and footer.
The footers have a horizontal line directly above the words.
Finally it sets the position of the header and footer.
Following your advice I have a usable solution but I am most interested in the update you mention.
I found a very useful reference site http://latex2rtf.sourceforge.net/rtfspec_7.html
For others interested my final code is ...
procedure TForm3.RichViewEdit1SaveRTFExtra(...
RTFCode :=
'\margl1150\margr1150\margt1438\margb1150'+
'{\header\pard\plain\posxc\fs23 Header text goes here\par}'+
'{\footer {\pard \brdrb \brdrs\brdrw10\brsp20 {\fs4\~}\par \pard} \pard\plain\qc\fs23 Footer text goes here Page \chpgn of {\field{\*\fldinst NUMPAGES }}\par}'+
'\titlepg'+
'{\headerf\pard\plain\posxc\fs23 First page Header\par}'+
'{\footerf {\pard \brdrb \brdrs\brdrw10\brsp20 {\fs4\~}\par \pard} \pard\plain\qc\fs23 First page Footer\par}'+
'\headery800'+
'\footery800';
This sets margins left,right,top and bottom
Sets a default header and footer (with page numbering) plus a separate first page header and footer.
The footers have a horizontal line directly above the words.
Finally it sets the position of the header and footer.