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.

798 Chapter 32 Generating Personalized Documents in Portable Document Format (PDF)<br />

Listing 32.6<br />

Continued<br />

pdf_stroke($pdf);<br />

// add heading<br />

$font = pdf_findfont($pdf, $fontname, 'host', 0);<br />

if ($font) {<br />

pdf_setfont($pdf, $font, 48);<br />

}<br />

$startx = ($width - pdf_stringwidth($pdf, '<strong>PHP</strong> Certification',<br />

$font, '12'))/2;<br />

pdf_show_xy($pdf, '<strong>PHP</strong> Certification', $startx, 490);<br />

// add text<br />

$font = pdf_findfont($pdf, $fontname, 'host', 0);<br />

if ($font) {<br />

pdf_setfont($pdf, $font, 26);<br />

}<br />

$startx = 70;<br />

pdf_show_xy($pdf, 'This is to certify that:', $startx, 430);<br />

pdf_show_xy($pdf, strtoupper($name), $startx+90, 391);<br />

$font = pdf_findfont($pdf, $fontname, 'host', 0);<br />

if ($font)<br />

pdf_setfont($pdf, $font, 20);<br />

pdf_show_xy($pdf, 'has demonstrated that they are certifiable '.<br />

'by passing a rigorous exam', $startx, 340);<br />

pdf_show_xy($pdf, 'consisting of three multiple choice questions.',<br />

$startx, 310);<br />

pdf_show_xy($pdf, "$name obtained a score of $score".'%.', $startx, 260);<br />

pdf_show_xy($pdf, 'The test was set <strong>and</strong> overseen by the ', $startx, 210);<br />

pdf_show_xy($pdf, 'Fictional Institute of <strong>PHP</strong> Certification',<br />

$startx, 180);<br />

pdf_show_xy($pdf, "on $date.", $startx, 150);<br />

pdf_show_xy($pdf, 'Authorised by:', $startx, 100);<br />

// add bitmap signature image<br />

$signature = pdf_load_image($pdf, 'png', '/Program Files/Apache Software<br />

Foundation/Apache2.2/htdocs/phpmysql4e/chapter32/signature.png', '');<br />

pdf_fit_image($pdf, $signature, 200, 75, '');<br />

pdf_close_image($pdf, $signature);

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

Saved successfully!

Ooh no, something went wrong!