Control Reference > VSPrinter Control > VSPrinter Properties > TextRTF Property |
Renders RTF text on the page at the current cursor position.
[form!]VSPrinter.TextRTF = value As String
RTF (Rich Text Format) allows you to embed special formatting codes into the text to be printed. You may obtain RTF text from many sources, including RTF files created by WordPad, Microsoft® Word, or from a RichEdit control. Alternatively, you may choose to create the RTF text manually.
All RTF text starts with a header section that contains a font table and a color table (and possibly other optional elements). If you assign an RTF string without an RTF header to the TextRTF property, VSPrinter will realize that the header is missing and will create one on the fly. This automatically generated header contains a single font and a single color (based on the control's Font and TextColor properties.) Because there is a single font in the automatically generated header, you may change the font style and size, but not its name (typeface).
For example, the following code prints a string with embedded bold and italics:
vp.TextRTF = "Hello. This is {\b BOLD}, and this is {\i ITALICS}."
If you need to combine multiple typefaces into a single string, you must supply the RTF header yourself. The easiest way to do this is to create the document in WordPad, save it as RTF, then open the file in NotePad and tweak it.
For example, the following code prints a string with different fonts:
vp.TextRTF = "{\rtf1\ansi\deff0\deftab720" & _
"{\fonttbl{\f0\fswiss Arial;}" & _
"{\f1\froman Courier New;}}" & _
"{\colortbl\red0\green0\blue0;}" & _
"\f0\fs22 Hello. This is Arial and " & _
"this is {\f1 Courier}." & _
"}"
You can also use RTF text in cell tables, headers, footers, text boxes, and regular paragraphs. To do this, set the AutoRTF property to True and enclose the text you want to print in curly braces ("{}").
VSPrinter uses the Windows RichEdit component (RICHED20.DLL) to render RTF. RichEdit is powerful, but not as powerful as Microsoft® Word. In particular, RichEdit does not handle RTF tables, which means you cannot copy a table from Word and render it using the TextRTF property. VSPrinter can, however, export tables into RTF files which can then be read into Word.
Note: RTF is an extremely powerful format, but it is also fairly time-consuming to render. Use RTF only if you have to, because it will slow down the creation of your documents. |
String