13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Solution Overview<br />

791<br />

Listing 32.4<br />

Continued<br />

// send the generated document to the browser<br />

}<br />

?><br />

echo $output;<br />

This script produces a customized version of the PDF document.The document, shown<br />

in Figure 32.6, will print reliably on numerous systems, <strong>and</strong> is harder for the recipient to<br />

modify or edit.You can see that the PDF document in Figure 32.6 looks almost exactly<br />

like the RTF document in Figure 32.5.<br />

One problem with this approach is that the code runs quite slowly because of the<br />

regular expression matching required. Regular expressions run much more slowly than<br />

str_replace() that you could use for the RTF version.<br />

If you are going to match a large number of placeholders or try to generate many of<br />

these documents on the same server, you might want to look at other approaches.This<br />

issue would be less of a problem for a simpler template. Much of the bulk in this file is<br />

data representing the images.<br />

Figure 32.6<br />

The pdf.php script generates a certificate from a<br />

PDF template.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!