pdf_open_memory_image

(PHP 3 >= 3.0.10, PHP 4, PECL)

pdf_open_memory_image -- Opens an image created with PHP's image functions

Description

int pdf_open_memory_image ( resource pdfdoc, resource image )

The pdf_open_memory_image() function takes an image created with the PHP's image functions and makes it available for the pdf resource. The function returns a pdf image identifier.

例子 1. Including a memory image

<?php
$im
= imagecreate(100, 100);
$col = imagecolorallocate($im, 80, 45, 190);
imagefill($im, 10, 10, $col);
$pim = pdf_open_memory_image($pdf, $im);
imagedestroy($im);
pdf_place_image($pdf, $pim, 100, 100, 1);
pdf_close_image($pdf, $pim);
?>

See also pdf_close_image() and pdf_place_image().


add a note add a note User Contributed Notes
leela at leela dot ws
20-Nov-2002 02:36
note that in PHP 4.2.2 and PDF_lib 4.0.1 this function does not support more than 256 colors (only GD 1.x it seems).

WORKS:
$im = ImageCreate(100, 100);
$pim = pdf_open_memory_image($pdf, $im);

DOES NOT WORK:
$im = ImageCreateTrueColor(100, 100);
$pim = pdf_open_memory_image($pdf, $im);

DOES NOT WORK:
$im = ImageCreateFromJPEG("file.jpg");
$pim = pdf_open_memory_image($pdf, $im);
bob at nijman dot de
02-Aug-2001 09:13
I'm running PHP Version 4.0.6 on Win2000 and I also get a:

Warning: pdf_open_memory_image() is not supported in this PHP build
christian at wenz dot org
03-May-2001 06:10
not implemented in 4.0.5-Win32 yet, too - although Rasmus himself promised so in the Win32 mailing list ;-) scnr
so maybe in 4.0.6 ...
christian at wenz dot org
19-Apr-2001 05:05
under the Win32 platform, the function is _not_ implemented on PHP < 4.0.5 !