13.09.2016 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Listing 32.6<br />

Continued<br />

//draw rosette<br />

draw_star(665, 175, 32, 57, 10, $pdf, true);<br />

//outline rosette<br />

draw_star(665, 175, 32, 57, 10, $pdf, false);<br />

// finish up the page <strong>and</strong> prepare to output<br />

pdf_end_page($pdf);<br />

pdf_close($pdf);<br />

$data = pdf_get_buffer($pdf);<br />

// generate the headers to help a browser choose the correct application<br />

header('Content-type: application/pdf');<br />

header('Content-disposition: inline; filename=test.pdf');<br />

header('Content-length: ' . strlen($data));<br />

// output PDF<br />

echo $data;<br />

}<br />

function draw_star($centerx, $centery, $points, $radius,<br />

$point_size, $pdf, $filled) {<br />

$inner_radius = $radius-$point_size;<br />

for ($i = 0; $i

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

Saved successfully!

Ooh no, something went wrong!