05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Example 10-14. Creating an open note (continued)<br />

pdf_close($p);<br />

$buf = pdf_get_buffer($p);<br />

$len = strlen($buf);<br />

header("Content-Type: application/pdf");<br />

header("Content-Length: $len");<br />

header("Content-Disposition: inline; filename=note.pdf");<br />

echo $buf;<br />

pdf_delete($p);<br />

?><br />

The output of Example 10-14 is shown in Figure 10-15.<br />

Figure 10-15. Open note<br />

Changing the open argument to php_add_note( ) from 1 to 0 creates the output shown<br />

in Figure 10-16 (a closed note).<br />

Attaching Files to a PDF Document<br />

Arbitrary files can be attached to a PDF document. For example, a PDF version of<br />

this bookmight have attachments for each program, saving the pain of copying and<br />

pasting.<br />

To attach a file, use the pdf_attach_file( ) function:<br />

pdf_attach_file(pdf, llx, lly, urx, ury, filename, description, author,<br />

content_type, icon);<br />

260 | Chapter 10: PDF<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.

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

Saved successfully!

Ooh no, something went wrong!