Specifications
On service driven sites, we sometimes need to deliver personalized documents, generated in
response to input from our visitors. This can be used to provide an automatically filled in form
or to generate personalized documents, such as legal documents, letters, or certificates.
Our example in this chapter will present a user with an online skill assessment page and
generate a certificate.
We will explain
• How to use PHP string processing to integrate a template with a user’s data to create a
Rich Text Format (RTF) document
• How to use a similar approach to generate a Portable Document Format (PDF) document
• How to use PHP’s PDFlib functions to generate a similar PDF document
The Problem
We want to be able to give our visitors an exam consisting of a number of questions. If they
answer enough of the questions correctly, we will generate a certificate for them to show that
they have passed the exam.
So that a computer can mark them easily, our questions will be multiple choice, consisting of
a question and a number of potential answers. Only one of the potential answers for each
question will be correct.
If a user achieves a passing grade on the questions, he will be presented with a certificate.
Ideally, the file format for our certificate should
1. Be easy to design
2. Be able to contain a variety of different elements such as bitmap and vector images
3. Result in a high quality printout
4. Only require a small file to be downloaded
5. Be generated almost instantly
6. Be at a low cost to produce
7. Work on many operating systems
8. Be difficult to fraudulently duplicate or modify
9. Not require any special software to view or print
10. Display and print consistently for all recipients
Like many decisions we need to make from time to time, we will probably need to compro-
mise when choosing a delivery format to meet as many of these ten attributes as possible.
Building Practical PHP and MySQL Projects
P
ART V
744
36 7842 CH30 3/6/01 3:40 PM Page 744