Specifications

We can build a complex document, such as the one shown in Figure 30.4, easily using a word
processor.
Generating Personalized Documents in Portable Document Format (PDF)
C
HAPTER 30
30
GENERATING
PERSONALIZED
DOCUMENTS IN
PDF
759
FIGURE 30.4
Using a word processor, we can create a complex, attractive template easily.
Our template includes placeholders such as <<NAME>> to mark the places where dynamic data
will be inserted. It is not important what these place holders look like. We are using a mean-
ingful description between two sets of angled braces. It is important that we choose placehold-
ers that are highly unlikely to accidentally appear in the rest of the document. It will help you
to lay out your template if the placeholders are roughly the same length as the data they will
be replaced with.
The placeholders in this document are <<NAME>>, <<Name>>, <<score>>, and <<mm/dd/yyyy>>.
Note that we are using both NAME and Name, because we intend to use a case sensitive
method to replace them.
Now that we have a template, we need a script to personalize it. This script is called rtf.php,
and its code is shown in Listing 30.3.
LISTING 30.3 rtf.phpScript to Produce a Personalized RTF Certificate
<?
// check we have the parameters we need
36 7842 CH30 3/6/01 3:40 PM Page 759