Page 307 - Open Soource Technologies 304.indd
P. 307
Unit 12: Portable Document Format
Notes
$font = pdf_findfont($p,’Helvetica-Bold’,’host’,0);
pdf_setfont($p,$font,38.0);
pdf_show_xy($p,”$x by $y”,425,750);
pdf_end_page($p);
pdf_close($p);
$buf = pdf_get_buffer($p);
$len = strlen($buf);
header(“Content-Type: application/pdf”);
header(“Content-Length: $len”);
header(“Content-Disposition: inline; filename=images.pdf”);
echo $buf; pdf_delete($p);
?>
Figure 12.7 shows the output of Example.
Figure 12.7: Placed and Scaled Images
125 by 66
The scaled versions of the PHP logo in Example kept their original proportions. To do
nonproportional scaling of an image, you must temporarily scale the coordinate system via a
call to pdf_scale( ):
pdf_scale(pdf, xscale, yscale);
All subsequent coordinates will be multiplied by the xscale and yscale values.
The Example shows nonproportional scaling in action. Note that we had to compensate for
the coordinate system scaling in the pdf_place_image( ) call to have the image show up in the
right place.
LOVELY PROFESSIONAL UNIVERSITY 301