11 Vote

RTF: Insert Footer and Header on each Page

Question by Filer | 2015-08-26 at 17:08

I would like to create an RTF document manually. Using the following code, I have managed to create a document consisting of two pages.

{\rtf1\ansi\deff0
{\fonttbl{\f0 Times New Roman;}}
First Page\page
Second Page
}

However, now I would like to insert a footer and a header into the document, I mean some text that is appearing on each page of the document either at the top of the page or the bottom.

Is there any comfortable possibility for doing that in the RTF specification?

ReplyPositiveNegative
2Best Answer2 Votes

You can easily create a footer and a header for your RTF by just inserting the section {\footer } and {\header } into the document. Depending on what you need, you can put only one of those sections into your document or both. Here is an example:

{\rtf1\ansi\deff0
{\fonttbl{\f0 Times New Roman;}}
{\header This text will appear in Header}
{\footer This text will appear in Footer}
First page\page
Second page
}

Within the section, you can use and apply the normal formattings available in the RTF standard, for example:

{\header\pard\b Bold Header Text\par}
{\header\pard\i Italic Header Text\par}

Additionally, there are some types of \header and \footer you can use:

VariantExplanation
\headerHeader on all pages
\headerfHeader for the first page only
\headerlHeader on left pages only
\headerrHeader on right pages only
\footerFooter on all pages
\footerfFooter for the first page only
\footerlFooter on left pages only
\footerrFooter on right pages only

For example, if you would like to have an individual footer only for the first page of the document as well as individual footers only displayed on left or right pages, you have to create a separate section for \footerf, \footerl and \footerr in which you can define the corresponding content.
2015-08-27 at 09:12

ReplyPositive Negative
Reply

Related Topics

PHP: Sending an E-Mail

Tutorial | 0 Comments

RTF: Center Text in Footer

Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.