Rich-Text Format Specification V. 2 Introduction 2 rtf syntax 2 Conventions of an rtf reader 4

Download 1.09 Mb.
Date conversion29.04.2016
Size1.09 Mb.
  1   2   3   4   5   6   7   8   9   ...   15

Rich Text Format Specification v. 1.2 Page

Rich-Text Format Specification v. 1.2

Introduction 2

RTF Syntax 2

Conventions of an RTF Reader 4

Change Destination 4

Change Formatting Property 5

Insert Special Character 5

Insert Special Character and Perform Action 5

Formal Syntax 5

Contents of an RTF File 5

Header 6

RTF Version 6

Character Set 6

Font Table 6

Code Page Support 8

Font Embedding 8

The File Table 8

Color Table 9

Style Sheet 10

Revision Marks 11

Document Area 12

Information Group 12

Document-Formatting Properties 13

Section Text 17

Section-Formatting Properties 17

Headers and Footers 19

Paragraph Text 20

Paragraph-Formatting Properties 20

Tabs 21

Bullets and Numbering 22

Paragraph Borders 24

Paragraph Shading 24

Absolute-Positioned Objects and Frames 25

Table Definitions 26

Character Text 29

Character-Formatting Properties 29

Associated Character Properties 32

Special Characters 33

Bookmarks 35

Pictures 35

Objects 38

Macintosh Edition Manager Publisher Objects 40

Drawing Objects 40

Footnotes 45

Annotations 46

Fields 46

Index Entries 47

Table of Contents Entries 48

Bidirectional language support 48

Alphabetic List of RTF Keywords 49


The rich-text format (RTF) standard is a method of encoding formatted text and graphics for easy transfer between applications. Currently, users depend on special translation software to move word-processing documents between different MS-DOS, Windows, OS/2 applications, and Apple Macintosh applications.

The RTF standard provides a format for text and graphics interchange that can be used with different output devices, operating environments, and operating systems. RTF uses the ANSI, PC-8, Macintosh, or IBM PC character set to control the representation and formatting of a document, both on the screen and in print. With the RTF standard, documents created under different operating systems and with different software applications can be transferred among those operating systems and applications.

Software that takes a formatted file and turns it into an RTF file is called a writer. Software that translates an RTF file into a formatted file is called a reader. An RTF writer separates the application's control information from the actual text and writes a new file containing the text and the RTF groups associated with that text. An RTF reader does the converse of this procedure.

RTF Syntax

An RTF file consists of unformatted text, control words, control symbols, and groups. For ease of transport, a standard RTF file can consist of only 7-bit ASCII characters. (Converters that communicate with Microsoft Word for Windows or Microsoft Word for the Macintosh should expect 8-bit characters.)

A control word is a specially formatted command that RTF uses to mark printer control codes and information that applications use to manage documents. A control word takes the following form:

\ LetterSequence<Delimiter>

Note that a backslash begins each control word.

The LetterSequence is made up of lowercase alphabetic characters between ‘a’ and ‘z’ inclusive. RTF is case sensitive, and all RTF keywords should be lowercase.

The Delimiter marks the end of an RTF control word, and can be one of the following:

á A space. In this case, the space is part of the control word.

á A digit or a hyphen (-), which indicates that a numeric parameter follows. The subsequent digit sequence is then delimited by a space or any character other than a letter or a digit. In other words, the parameter can be a positive or negative number. The range of the values for the number is  32767 through 32767. However, Microsoft Word for Windows, Word for OS/2, and Word for the Macintosh restrict the range to  31680 through 31680. If a numeric parameter immediately follows the control word, this parameter becomes part of the control word. The control word is then delimited by a space or a non alphabetic or non-numeric character in the same manner as any control word.

á Any character other than a letter or a digit. In this case, the delimiting character terminates the control word but is not actually part of the control word.

If a space delimits the control word, space does not appear in the document. Any characters following the delimiter, including spaces, will appear in the document. For this reason, you should use spaces only where necessary; do not use spaces merely to break up RTF code.

A control symbol consists of a backslash followed by a single, non-alphabetic character. For example, \ ~ represents a non-breaking space. Control symbols take no delimiters.

A group consists of text and control words or control symbols enclosed in braces ({}). The opening brace ({) indicates the start of the group and the closing brace (}) indicates the end of the group. Each group specifies the text affected by the group and the different attributes of that text. The RTF file can also include groups for fonts, styles, screen color, pictures, footnotes, annotations, headers and footers, summary information, fields, and bookmarks, as well as document-, section-, paragraph-, and character-formatting properties. If the font, style, screen-color, and summary-information groups and document-formatting properties are included, they must precede the first plain-text character in the document. These groups form the RTF file header. If the group for fonts is included, it should precede the group for styles. If any group is not used, it can be omitted. The groups are discussed in the following sections.

Certain control words control properties (such as bold, italic, keep together, and so forth) that have only two states. When such a control word has no parameter or has a non-zero parameter, it is assumed that the control word turns on the property. When such a control word has a parameter of 0 (zero), it is assumed that the control word turns off the property. For example, \ b turns on bold, whereas \ b0 turns off bold.

Certain control words, referred to as destinations, mark the beginning of a collection of related text which could appear at another position, or destination, within the document. Destinations may also be text which is used but should not appear within the document at all. An example of a destination is the \ footnote group, where the footnote text follows the control word. Destination control words and their following text must be enclosed in braces. Destinations added after the RTF specification published in the March 1987 Microsoft Systems Journal may be preceded by the control symbol \ *. This control symbol identifies destinations whose related text should be ignored if the RTF reader does not recognize the destination. (RTF writers should follow the convention of using this control symbol when adding new destinations or groups.) Destinations whose related text should be inserted into the document even if the RTF reader does not recognize the destination should not use \ *. All destinations that were not included in the March 1987 revision of the RTF specification are shown with \ * as part of the control word.

Formatting specified within a group affects only the text within that group. Generally, text within a group inherits the formatting of the text in the preceding group. However, Microsoft implementations of RTF assume that the footnote, annotation, header, and footer groups (described later in this chapter) do not inherit the formatting of the preceding text. Therefore, to ensure that these groups are always formatted correctly, you should set the formatting within these groups to the default with the \ sectd, \ pard, and \ plain control words, and then add any desired formatting.

The control words, control symbols, and braces constitute control information. All other characters in the file are plain text. Here is an example of plain text that does not exist within a group:

{\rtf\ansi\deff0{\fonttbl{\f0\froman Tms Rmn;}{\f1\fdecor

Symbol;}{\f2\fswiss Helv;}}{\colortbl;\red0\green0\blue0;



green255\blue0;\red255\green255\blue255;}{\stylesheet{\fs20 \snext0Normal;}}{\info{\author John Doe}


{\nofpages1}{\nofwords0}{\nofchars0}{\vern8351}}\widoctrl\ftnbj \sectd\linex0\endnhere \pard\plain \fs20 This is plain text.\par}
The phrase “This is plain text” is not part of a group and is treated as document text.

As previously mentioned, the backslash ( \ ) and braces ({ }) have special meaning in RTF. To use these characters as text, precede them with a backslash, as in \ \ , \ {, and \ }.

  1   2   3   4   5   6   7   8   9   ...   15

The database is protected by copyright © 2016
send message

    Main page