PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Image Drawing

Zend_Pdf_Page class provides drawImage() method to draw image:

<?php
/**
 * Draw an image at the specified position on the page.
 *
 * @param Zend_Pdf_Resource_Image $image
 * @param float $x1
 * @param float $y1
 * @param float $x2
 * @param float $y2
 * @return Zend_Pdf_Page
 */
public function drawImage(Zend_Pdf_Resource_Image $image$x1$y1$x2$y2);

Image objects should be created with Zend_Pdf_Image::imageWithPath($filePath) method (JPG, PNG and TIFF images are supported now):

Example 676. Image drawing

<?php
...
// load image
$image Zend_Pdf_Image::imageWithPath('my_image.jpg');

$pdfPage->drawImage($image100100400300);
...

Important! JPEG support requires PHP GD extension to be configured.Important! PNG support requires ZLIB extension to be configured to work with Alpha channel images.

Refer to the PHP documentation for detailed information (http://www.php.net/manual/en/ref.image.php). (http://www.php.net/manual/en/ref.zlib.php).

Zend Framework