RTF (.rtf)

Background & Context

    • MIME type: application/rtf
    • RTF document file format.
    • Used for cross-platform exchange of formatted text documents.
    • Supported by most word processors.
    • RTF is an acronym for Rich Text Format.
    • 7-bit ASCII format.
    • Stores formatted text using a human-readable document markup language.
    • Developed since 1987 by Microsoft.

Import & Export

  • Import["file.rtf"] imports an RTF file as a Notebook expression.
  • Export["file.rtf",expr] exports a Notebook expression or elements of a notebook to RTF.
  • Import["file.rtf"] returns an expression of the form Notebook[].
  • Import["file.rtf",elem] imports the specified element from an RTF file.
  • Import["file.rtf",{elem,suba,subb,}] imports a subelement.
  • Import["file.rtf",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file","RTF"] or Import["file",{"RTF",elem,}].
  • Export["file.rtf",expr,elem] creates an RTF file by treating expr as specifying element elem.
  • Export["file.rtf",{expr1,expr2,},{{elem1,elem2,}}] treats each expri as specifying the corresponding elemi.
  • Export["file.rtf",expr,opt1->val1,] exports expr with the specified option elements taken to have the specified values.
  • Export["file.rtf",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
  • See the following reference pages for full general information:
  • Import, Exportimport from or export to a file
    CloudImport, CloudExportimport from or export to a cloud object
    ImportString, ExportStringimport from or export to a string
    ImportByteArray, ExportByteArrayimport from or export to a byte array

Notebook Interface

  • Save As exports the active notebook as an RTF file.

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Summary"summary of the file
    "Rules"list of rules for all available elements
  • Data representation elements:
  • "Notebook"a Notebook version of the RTF file
    "NotebookObject"RTF file converted to NotebookObject
  • Import and Export use the "Notebook" element by default for RTF files.

Examples

Basic Examples  (2)

Show the Import elements available in an RTF sample file:

Import this file as a Notebook expression:

Export a Cell expression containing typeset math to RTF:

Convert the generated file to a Notebook expression: