Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 14 in printed book and digital formats -- plus a one-year subscription so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

PDF:

Beginner's Corner

Printing 201

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
Resource File(s):

Download Icon 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:

Sub Open()

dim tin as textInputStream

tin = textInputStream.open(getFolderItem("sampletext.rtf"))

if tin <> nil then me.styledText.RTFData = tin.readAll

End Sub

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.


 


|

 


Weblog Commenting and Trackback by HaloScan.com