Introduction to RTF

<< Click to Display Table of Contents >>

Navigation:  Programming Techniques > RTF - Rich Text Format >

Introduction to RTF

Previous pageReturn to chapter overviewNext page

The following is a short introduction into RTF. For a complete description, we recommend the RTF specification white-paper of Microsoft, which can be found for example at www.microsoft.com.

RTF can be seen as a layout description language. RTF knows a large set of keywords for controlling the layout. Some of the keywords may be followed by a parameter or a group of parameters. VPE does not support all RTF keywords - but the most important to have powerful control over the appearance and layout of text. For a complete list of supported keywords by VPE see "RTF Properties processed by VPE".

 

The most important on the RTF syntax is the use of nested groups. Groups are nested by { }. For example, to make a few words bold, the RTF stream would look like that:

"Hello, {\b this is bold text} and this is normal text."

The "\b" is the RTF command to set the bold property to on. By nesting it, only the text between the { } is shown in bold.

There is no restriction in the depth of nesting. Example:

"Hello, {\b this is bold text{\fs48  and this is 24pt. bold text {\i 24pt.,

bold, italic} 24pt. bold} only bold} and this is normal text."

Note that font-sizes in RTF are specified in 0.5 pt. sizes. VPE computes them internally into full point sizes. If the number of braces is unbalanced, VPE will not process the RTF text.

Instead of using nested structures, there is also the possibility of working with parameters."\b0" for example means "turn bold off". So the last example above could be implemented as follows:

"Hello, \b this is bold text\fs48  and this is 24pt. bold text \i 24pt.,

bold, italic \i0 24pt. bold \fs20 only bold \b0 and this is normal text."