About Arbortext Styler > Publishing XML Documents as RTF Files > Publishing Headers and Footers in RTF Files
Publishing Headers and Footers in RTF Files
Publishing headers requires knowledge of how headers and page sets are created and used in Arbortext Styler. Fortunately almost all of the stylesheet development for page headers and footers in other outputs such as PDF serves equally well for, or at least does not interfere with, RTF output. The main difference is some additional work that defines how to create dynamically active headers for a Word document in cases where the Word document may be edited by the end user.
Consider the concept that output to RTF is different from most other outputs because the published document may be destined for an editing system such as Word. Most other outputs are documents destined for read-only viewers of various types, such PDF files, HTML files, print publishing, and HTML Help. Because the RTF document might be edited significantly with extensive addition or reduction of pages, it is not sufficient to simply publish hard-coded page numbers and header content.
Page numbering is automatically supported by virtue of Word PAGEREF fields, so simple page footers require no extra effort. Headers with dynamic title information requires some minor additions.
The easiest way to implement dynamic header information is by using the STYLEREF field in conjunction with RTF style names associated with division titles. For example, with the axdocbook doctype, if you wish to insert the current chapter title into the RTF header, use the following steps:
Inserting a Chapter Title into the RTF Header
1. In Arbortext Styler, select the title in chapter context in the Elements list.
2. Assign an RTF style name to the context, for example the default auto-generated name chapter/title, using the steps described below. This will ensure all chapter titles are published to RTF with this designated paragraph style name.
a. In the RTF category, check the User-defined option in the RTF style name generation field. You may need to deselect the Default (None) option to enable you to make the selection.
b. In the RTF style type field, select the Paragraph option.
c. In the RTF style name field, leave the default style chapter/title that is added by Arbortext Styler.
3. Create the UFE _ufe:RTFHeader. Check the View > User Formatting Elements menu option to ensure your new UFE is shown in the Elements list.
4. Assign the Inline style to ufe:RTFHeader, via the Edit > Style menu option.
5. Assign the RTF field STYLEREF to _ufe:RTFHeader by following the steps described below:
a. Select the default context of _ufe:RTFHeader in the Elements list.
b. In the RTF category, click the Edit button in the RTF field field. The Field dialog box opens.
c. In the Field name field, select STYLEREF from the drop down list.
6. Set the field values for STYLEREF as follows: .
Set the field instruction STRING to chapter/title. Ensure the Use box is checked.
This is an image of the Field dialog box, with the Field name field set to STYLEREF, and the instruction STRING shown in the list. The instruction has the Use option checked and the value “chapter/title” set in the Value column.
7. Modify the odd-page and even-page header blocks for the mainbody-page Page Set by inserting the newly-created _ufe:RTFHeader into the generated text that defines each header. In the case of the distributed axdocbook stylesheet, the new header markup would be:
Because _ufe:RTFHeader only publishes a Word field, and because RTF-related features are ignored by all other outputs, the RTF-specific markup has no affect on non-RTF outputs. In turn, the DivisionReference markup has no effect on RTF output, meaning the two different types of markup can coexist if desired.
In the previous example, the content and level of granularity is easily managed with Arbortext Styler through UFEs. _ufe:RTFHeader could, for example, include its own generated text, such as the prefix Chapter, or the header could also include lower-level information such as sect1 titles instead of just chapter titles by creating additional UFE elements as needed.