Specifications

programs; and variable quality printing. In addition, although HTML can include any type
of external element, the capability of the browser to display or use these elements cannot be
guaranteed for unusual types.
Word Processor Formats
Particularly for intranet projects, providing documents as word processor documents makes
some sense. However, for an Internet project, using a proprietary word processor format will
exclude some visitors, but given its market dominance, Microsoft Word would make sense.
Most users will either have access to Word or to a word processor that will try to read Word
files.
Windows users without Word can download the freeware Word Viewer from
http://www.microsoft.com/office/000/viewers.htm
Generating a document as a Microsoft Word document has some advantages. As long as you
have a copy of Word, designing a document is easy. We have very good control over the
printed appearance of our documents and a lot of flexibility with its contents. You can also
make it relatively difficult for the recipient to modify by telling word to ask for a password.
Unfortunately, Word files can be large, particularly if they contain images or other complex
elements. There is also no easy way to generate them dynamically with PHP. The format is
documented, but is a binary format and the format documentation comes with license
conditions.
Rich Text Format
Rich Text Format or RTF gives us most of the power of Word, but the files are easier to gener-
ate. We still have flexibility over layout and formatting of the printed page. We can still include
elements such as vector or bitmap images. We can still be fairly sure that the user will see a
similar result to us when they view or print the document.
RTF is Microsoft Words text format. It is intended as an interchange format to transfer docu-
ments between different programs. In some ways, it is similar to HTML. It uses syntax and key
words rather than binary data to convey formatting information. It is therefore relatively human
readable.
The format is well documented. The specification is freely available and can be found here:
http://msdn.microsoft.com/library/specs/rtfspec.htm
The easiest way to generate an RTF document is to choose a Save As RTF option in your word
processor. As RTF files contain only text, it is possible to generate them directly and existing
ones can easily be modified.
Building Practical PHP and MySQL Projects
P
ART V
746
36 7842 CH30 3/6/01 3:40 PM Page 746