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.

Figure 10-1. Hello world in a PDF document<br />

Setting Metadata<br />

The pdf_set_info( ) function inserts information fields into the PDF file:<br />

pdf_set_info(pdf, fieldname, value);<br />

There are five standard field names: Subject, Author, Title, Creator, and Keywords.<br />

You can also add arbitrary information fields, as we did in Example 10-1.<br />

In addition to informational fields, the pdflib library has various parameters that you<br />

can change with pdf_get_parameter( ) and pdf_set_parameter( ):<br />

$value = pdf_get_parameter(pdf, name);<br />

pdf_set_parameter(pdf, name, value);<br />

A useful parameter to set is openaction, which lets you specify the zoom (magnification)<br />

of the file when it’s opened. The values "fitpage", "fitwidth", and "fitheight"<br />

fit the file to the complete page, the width of the page, and the height of the page,<br />

respectively. If you don’t set openaction, your document is displayed at whatever<br />

zoom the viewer had set at the time the document was opened.<br />

Creating a Page<br />

A page starts with a call to pdf_begin_page( ) and ends with a call to pdf_end_page( ):<br />

pdf_end_page(pdf);<br />

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

Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.<br />

Documents and Pages | 235

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

Saved successfully!

Ooh no, something went wrong!