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-3. Changing the origin (continued)<br />

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

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

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

echo $buf;<br />

pdf_delete($pdf);<br />

?><br />

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

Figure 10-3. Changing the origin<br />

The pdf_translate( ) function moves the origin to the top of the page, and pdf_<br />

scale( ) inverts the Y-axis coordinates. To avoid producing text that can be read only<br />

in a mirror, we set the horizscaling parameter.<br />

Text Functions<br />

PDF files have the concept of the current text position. It’s like a cursor—unless you<br />

specify another location, when you insert text it appears at the current text location.<br />

You set the text location with the pdf_set_textpos( ) function:<br />

pdf_set_textpos(pdf, x, y);<br />

Once you have positioned the cursor, use the pdf_show( ) function to draw text there:<br />

pdf_show(pdf, text);<br />

After you call pdf_show( ), the cursor moves to the end of the inserted text.<br />

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

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

Text | 239

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

Saved successfully!

Ooh no, something went wrong!