Name

jfif_embed -- embed a jfif (jpeg) image into the PDF

Synopsis

int jfif_embed ( string data )

Description

This function is used to insert an external JFIF file into the PDF file. (JFIF files are commonly called jpeg files, this is not entirely accurate, however)

The single parameter data should contain the raw, binary JFIF data. The function returns a library ID that must be used to paint the embedded image, or false on error.

Examples

Assuming that image.jpg is a valid JFIF file, the following code will extract the file data, embed it into the PDF file, and paint it to a page.

$page = $pdf->new_page("letter");
$fh = fopen("image.jpg", "r");
$filedata = fread($fh, filesize("image.jpg"));
fclose($fh);
$image = $pdf->jfif_embed($filedata);
$placement = $pdf->image_place($image, 10, 10, $page);

See Also

This function is really only a convenience wrapper around ->image_raw_embed() that extracts the necessary data for embedding the image from the jfif stream itself.

History

Bugs

Some PDF viewers have problems displaying images in certain formats. Before reporting bugs concerning images, ensure that you are using the latest version of your PDF viewer program. Also be sure that the image is not created with unusual jfif options (try creating it with all special optimizations turned off).