The basics of printing styled text
Issue: 9.4 (May/June 2011)
Author: Marc Zeedar editor-at-rbdeveloper.com
Article Description: No description available.
Article Length (in bytes): 11,110
Starting Page Number: 72
RBD Number: 9409
9409.zip Updated: Monday, May 2, 2011 at 7:59 PM
Related Link(s): None
Known Limitations: None
Excerpt of article text...
In our last issue I introduced the topic of printing by demonstrating a print-preview feature. However, that example did not support styled text. Today we'll look at printing styled text using Real Studio's styledTextPrinter object.
In the previous demo, any text formatting we did programmatically, via our printing code. For instance, I had a "title" checkbox that if you checked it, would center and bold the first lines of the text (presumably title and author, at least in the included example text). Today I've taken that same sample story and created an RTF file of it. This will preserve the text's formatting.
To do that, we first need to make our textArea support styled text by checking the styled property. Then in its Open event we put this code:
dim tin as textInputStream
tin = textInputStream.open(getFolderItem("sampletext.rtf"))
if tin <> nil then me.styledText.RTFData = tin.readAll
This simply reads the sample text file and sticks it into the RTFData property of the textArea's styledText property. When you run the application, the text, complete with styles, is displayed (see Figure 1).
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.