Skip to Main Content
RTF Pocket Guide
book

RTF Pocket Guide

by Sean M. Burke
July 2003
Intermediate to advanced content levelIntermediate to advanced
158 pages
3h 6m
English
O'Reilly Media, Inc.
Content preview from RTF Pocket Guide

Chapter 3. Example Programs

So far, this book has approached RTF as a format that means something in and of itself. But RTF, like any document format, makes sense only in terms of how it is used—namely, how it is formatted and read. The issue of parsing RTF is larger than can be dealt with in this brief guide, but these simple RTF-generating programs demonstrate the basic issues involved in having programs that write RTF documents. The examples are of simple utilities that each use some particular features of RTF.

The programs are all in relatively simple Perl, with an explanation before each, and comments in the code. If you want to generate your own RTF documents from Perl, have a look at the helpful RTF-writing modules in CPAN (located at http://search.cpan.org), notably RTF::Writer and RTF::Generator. I don’t actually use these modules in the following examples, because the examples simply demonstrate RTF without detouring through the APIs of the RTF-writing modules.

A Datebook Generator

This program starts a new RTF file, writes an RTF prolog, writes a series of paragraphs (one at a time, in each pass through the while loop), and then closes the document with a single } character. Each paragraph that it writes is a heading for each day’s worth of space in a datebook (which can be printed out and bound, so you have someplace to pencil in notes about upcoming appointments, deadlines, brunches, court dates, box socials, and the like). You can get a blank space between the paragraphs ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Software Architect’s Handbook

Software Architect’s Handbook

Joseph Ingeno
How to Keep Calm and Carry On

How to Keep Calm and Carry On

Daniel Freeman, Jason Freeman

Publisher Resources

ISBN: 9781449302047Supplemental ContentErrata Page