Rtf syntax



Download 154.15 Kb.
Page2/6
Date conversion29.04.2016
Size154.15 Kb.
1   2   3   4   5   6

The Style Sheet

The style sheet group begins with the control word \stylesheet. This group contains definitions and descriptions of the various styles used in the document. The style sheet is declared only once, in the RTF file header. All styles in the document's style sheet can be included, even if not all the styles are used.


In some applications, styles are based on, or are the basis for, other styles. In these cases, two other control words can be used


Control word

Meaning

\sbasedonn

Defines the number of the style on which current style is based

\snextn

Defines next style associated with current style; if omitted, next style is the current style

An example of an RTF style sheet and styles is shown in the following example. In this example, Postscript is declared but not used. Some of the control words in this example are discussed in the following sections.


É
{\stylesheet{\fs20 \sbasedon222\snext0 Normal;}{\s1\qr\fs20

AÑ\sbasedon0\snext1 FLUSHRlGHT;}{\s2\fi-720\li720\fs20\ri2880\fs20

\sbasedon0\snext2 IND;}}
É
\widowctrl\ftnbj\ftnrestart\sectd\linex0\endnhere

\pard\plain\fs20 This is Normal style.

\par\pard\plain\s1

BÑThis is right justified. I call this style FLUSHRIGHT.

\par\pard\plain\s2

This is an indented paragraph. I call this style IND. It produces a hanging indent.


\par}
This is Normal Style.
This is right justified. I call this style FLUSHRIGHT.

This is an indented paragraph. I call this style IND.

It produces a hanging indent.
A Style sheet

B Styles applied to text



The Color Table


Screen colors, character colors, and other color information are contained in the color table group. The control word \colortbl begins this group. Values for red, green, blue, and the foreground and background colors are shown in the following list. These parameter values correspond to the color indexes used by Microsoft Windows (0-255). Each color table entry is defined by the amount of red, green, and blue it has. For more information on color setup, see your Windows documentation.


The following are valid control words for this group


Control word

Meaning

\redn

Red index

\greenn

Green index

\bluen

Blue index

\cfn

Foreground color (default is 0)

\cbn

Background color (default is 0)

Each definition must be delimited by a semicolon, even if the definition is omitted. If a color definition is omitted, the RTF reader uses its default color. In the example below, three colors are defined. The first color is omitted, as shown by the semicolon following the \colortbl control word.


{\colortbl;\red0\green0\blue0;\red0\green0\blue255;}
The following example defines a block of text in color (where supported). Note that the cf/cb index is the index of an entry in the color table, which represents a red/green/blue color combination.
É
{\f1\cb1\cf2 This is colored text. The background is color 1 and the foreground is color 2.}
If the file is translated by software that does not display color, this group is ignored.

Pictures

An RTF file can include picture files composed with other applications. These files are in hexadecimal (default) or binary format. The control word \pict begins this group. Control words that define and describe the picture parameters follow the \pict control word.



These control words are listed in the table that follows. Some measurements in this table are in twips; a twip is one-twentieth of a printer's point. The control words for picture border patterns (\brdrs, \brdrdb, \brdrth, \brdrsh, \brdrdot, and \brdrhair) are ignored when translated into Microsoft Word for the Macintosh, which uses character properties to make borders.


Control word

Meaning

\brdrs

Single border for picture

\brdrdb

Double border for picture

\brdrth

Thick border for picture

\brdrsh

Shadow border for picture

\brdrdot

Dotted border for picture

\brdrhair

Hairline border for picture

\macpict

Source of picture is Macintosh Quick Draw

\wmetafilen

Source of picture is Windows metafile; argument identifies the metafile type; default is 1 (MM_TEXT)

\wbitmapn

Source of picture is a bitmap; argument identifies the bitmap type; default is 0 (logical bitmap)

\picwn

xExt field if picture is metafile; picture width in pixels if picture is bitmap or from Macintosh Quick Draw

\pichn

yExt field if picture is metafile; picture height in pixels if picture is bitmap or from Macintosh Quick Draw

\picwGoaln

Desired width of picture in twips

\pichGoaln

Desired height of picture in twips

\picscalexn

Horizontal scaling value; argument is a value between 1 and 100 (default is 10)

\picscaleyn

Vertical scaling value; argument is a value between 1 and 100 (default is 10)

\picscaled

Scales picture to fit within specified frame; used only with \macpict pictures

\piccroptn

Top cropping value in twips; positive value crops toward center of picture; negative value crops away from center, adding space border around picture (default is 0)

\piccropbn

Bottom cropping value in twips; positive value crops toward center of picture; negative value crops away from center, adding space border around picture (default is 0)

\piccropln

Left cropping value in twips; positive value crops toward center of picture; negative value crops away from center, adding space border around picture (default is 0)

\piccroprn

Right cropping value in twips; positive value crops toward center of picture; negative value crops away from center, adding space border around picture (default is 0)

\wbmbitspixeln

Bitmap bits/pixel (default is 1)

\wbmplanesn

Number of bitmap planes (default is 1)

\wbmwidthbytesn

Bitmap width in bytes

\binn

Picture is in binary format; numeric parameter is number of bytes to follow

The \wbitmap control word is optional; if neither \wmetafile nor \macpict is specified, the picture is assumed to be a Windows bitmap.


Be careful with spaces following control words when dealing with pictures in binary format. When reading files, RTF considers the first space the delimiter and subsequent spaces part of the document text. Therefore, any extra white space is attached to the picture, with unpredictable results.
RTF writers should not use the carriage-return-line-feed (CRLF) combination to break up pictures in binary format. In this case, the CRLF will be treated as literal text and considered part of the picture data.
The picture in hexadecimal or binary format follows the picture group control words. The following example illustrates the group format and the result.
{\pict\wbitmap0\picw170\pich77\wbmbitspixel1\wbmplanes1

\wbmwidthbytes22\picwgoal505

\pichgoal221

\picscalex172

\picscaley172

4912000000000273023d1101a030

3901000a000000000273023d98

0048000200000275

0240000200010275023e000000000

273023dO00002b90002b90002

b90002b90002b9

0002b90002b90002b90002b90002b90002

b92222b90002b90002b90

002b90002b9

D002b90002b90002b90002b9000
A Source

B Width


C Height

D Bits per pixel

E Bitmap planes

F Width of picture in bytes

G Desired picture width

H Desired picture height

I Horizontal scaling value

J Vertical scaling value

K Hexadecimal data

1   2   3   4   5   6


The database is protected by copyright ©essaydocs.org 2016
send message

    Main page