05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

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

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

Example 10-13. Specifying a link (continued)<br />

$im = pdf_open_jpeg($p, "php.jpg");<br />

$x = pdf_get_value($p, "imagewidth", $im);<br />

$y = pdf_get_value($p, "imageheight", $im);<br />

pdf_begin_page($p,612,792);<br />

pdf_place_image($p, $im, 50, 700, 1.0);<br />

pdf_set_border_style($p, "solid", 0);<br />

pdf_add_weblink($p,50,700,50+$x,700+$y,"http://www.php.net");<br />

pdf_end_page($p);<br />

pdf_close_image($p, $im);<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=link.pdf");<br />

echo $buf;<br />

pdf_delete($p);<br />

?><br />

Other PDF Features<br />

PDF documents support a variety of other features, such as annotations, attached<br />

files, and page transitions. These features can also be manipulated with pdflib.<br />

Note Annotations<br />

Notes can be added on top of a PDF document using pdf_add_note( ):<br />

pdf_add_note(pdf, llx, lly, urx, ury, contents, title, icon, open);<br />

Specify the note area with two points: the lower-left corner (llx,lly) and upperright<br />

corner (urx,ury). The contents parameter holds the text of the note (maximum<br />

size 64 KB). The maximum size of the title is 255 characters. The icon parameter<br />

indicates which icon should represent the note when it is closed (allowable values are<br />

"comment", "insert", "note", "paragraph", "newparagraph", "key", and "help"). The<br />

open parameter indicates whether the note should be open or closed by default.<br />

Example 10-14 creates an open note on a page with the note icon.<br />

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

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

Saved successfully!

Ooh no, something went wrong!