RTF

From MobileRead

Jump to: navigation, search

RTF (Rich Text Format) is an word processor interchange format developed by Microsoft to facilitate the exchange of documents between different tools and different operating systems.

Contents

Description

Files in this format will usually have an .rtf extension. The first RTF reader and writer shipped in 1987 as part of Microsoft Word 3.0 for Macintosh. It is the native save format for WordPad files. Some eBook readers can read files this format but it is fairly verbose so the file sizes will be larger.

RTF is an example of a markup language and uses pure text even for graphics by encoding the binary. It is capable of representing fairly complicated layouts.

When an eBook reader claims to read RTF it does not mean that it supports all of the fonts, or all of the available constructions.

RTF has two sections in the file, a header and a body. The header contains default information for the file such as the default font size and may contain metadata. If the file is loaded into an editor and then saved some or all of the metadata may be lost. WordPad for example saves files natively in RTF format but does not support metadata.

Tools

Just about every word processor on the planet can support RTF files. However there are differences in the way the files are produced.

  • WordPad uses RTF as its native format. It does not support images or metadata. It has a very compact footprint for files.
  • MS Word uses RTF as an exchange format. It support all features but produces a larger file than some others due to the fact that it includes information about every change to the file. Every time you save an RTF in MS word the file size will increase.

Syntax

RTF files include data and control structures. The control structures include:

  • Control Words - begin with a \ and consist of case sensitve letters followed by a delimiter. A delimiter can be a space (the space itself will be ignored), a number or - indicating a parameter for the control word, or another character which will start a new sequence.
  • Control Symbols - begin with a \ and consist of one special character. An example is \~ which is the symbol for a non-breaking space.
  • Groups - are delimited with { and } and are used to specify the text and the attributes of that text.
  • Destinations are special control words that specify that the text goes somewhere else in the document. An example is \footnote. The footnote itself will be defined as a group.

example

  • Here is an example of an RTF document using legal syntax.
{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard
This is some {\b bold} text.\par
}

This would be displayed as:

This is some bold text.

Bolding could also been achieved using \b bold\b0

  • Here is the same document saved in wordpad

{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033 {\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}} \viewkind4\uc1\pard\f0\fs24 This is some \b bold\b0 text.\par }

  • Here is a similar document saved in word 2002:

{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033 {\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f36\froman\fcharset238\fprq2 Times New Roman CE;} {\f37\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f39\froman\fcharset161\fprq2 Times New Roman Greek;}{\f40\froman\fcharset162\fprq2 Times New Roman Tur;}{\f41\froman\fcharset177\fprq2 Times New Roman (Hebrew);} {\f42\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f43\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f44\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255; \red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0; \red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0; \red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0; \red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;}{\*\cs10 \additive \ssemihidden Default Paragraph Font;}{\*\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3 \trpaddfr3\trcbpat1\trcfpat1\tblind0\tblindtype3\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl \tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv \ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}}{\*\rsidtbl \rsid604983\rsid1011638\rsid2916272\rsid3999307\rsid4476289 \rsid6029320\rsid8616248\rsid9443644\rsid9792149\rsid12854369\rsid12999621\rsid14312442 \rsid14449629\rsid15040078\rsid15151528\rsid15999791\rsid16668571}{\*\generator Microsoft Word 10.0.6846;}{\info{\title This word is bold}{\author Dale DePriest} {\operator Dale DePriest}{\creatim\yr2008\mo9\dy17\hr12\min45}{\revtim\yr2008\mo9\dy17\hr12\min45}{\version2} {\edmins2}{\nofpages1}{\nofwords2}{\nofchars17}{\*\company }{\nofcharsws18}{\vern16393}{\*\password 00000000}}{\*\xmlnstbl } \paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\gutter0 \widowctrl\ftnbj\aenddoc\grfdocevents0\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb \nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1800 \dgvorigin1440\dghshow1 \dgvshow1\jexpand\viewkind1\viewscale85\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine \htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl \snaptogridincell\allowfieldendsel\wrppunct\asianbrkrule\rsidroot15999791 \fet0 {\*\wgrffmtfilter 013f}\sectd \linex0\endnhere\sectlinegrid360\sectdefaultcl\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7 \pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain \ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\insrsid16668571 This }{\b\insrsid16668571\charrsid16668571 word}{\insrsid16668571 is bold.}{\insrsid4476289 \par }}

It says: This word is bold. Note that some metadata is included.

For more information

The specifications can be found on the Microsoft web site.

Personal tools
MobileRead Networks