O'Reilly logo

PHP Advanced for the World Wide Web: Visual QuickPro Guide by Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Images

While it is nice to be able to add lines and other shapes to your PDFs, to really add pizzazz, you can incorporate existing images. Using images in PDFs is essentially a three-step process:

1.
Open the image file.
2.
Place the image in the PDF.
3.
Close the image.

In actuality it can be a little more complicated than that once you take into account variable image size and such, but I've got a work-around for that issue, too.

For the most recent versions of PHP, open the image with pdf_open_image_file().

$image_pointer = pdf_open_image_file ($pdf, $format, $image_file); 

Exactly like creating a PDF, you assign a pointer to the open image file. The $format should refer to the format of the image itself: JPEG, GIF, PNG, or TIFF ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required