Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: PDF_load_image - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net

search for in the

PDF_makespotcolor" width="11" height="7"/> <PDF_load_iccprofile
Last updated: Wed, 01 Nov 2006
view this page in

PDF_load_image

(PECL)

PDF_load_image -- 画像ファイルをオープンする

説明

int PDF_load_image ( resource pdfdoc, string imagetype, string filename, string optlist )

さまざまなオプションをもとに、 ディスク上の画像ファイルや仮想画像ファイルをオープンします。



add a note add a note User Contributed Notes
PDF_load_image
Mike Zmuda
11-May-2006 10:40
This program takes a picture from a dynamic image selector (ie: banner ad selector software, or whatever,) and inserts it into your pdf.

You can use something like this to insert coupons on PDFs (such as register receipts, bills, receipts, etc...) just like they do at the supermarket checkout!

<?php
//Set up a document (PHP5 standard.)
$p = new PDFlib();
if (
$p->begin_document("", "") == 0) {
     die(
"Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "Homer");
$p->set_info("Author", "Lisa");
$p->set_info("Title", "Simpsons Image");
$p->begin_page_ext(612, 792, ""); // This is letter.

//Open the url for the image server we wish to use.
//    (When I say "Image Server," I mean any program or
//    script which will render image data as output. That
//    means that it has to output the raw data, unmodified,
//    such that it could be accessed like this in a standard
//    html instruction call:
//
//        <img src="http://site.com/getimg.php?pic=18">
//
//    If it adds border or other text, the data will be
//    corrupted, and thus cause the pdf to misrender.
if ($stream = fopen('http://site.com/getimg.php?pic=18', 'r')) {
  
$MyImage= stream_get_contents($stream, -1);
  
fclose($stream);
}

//First, create a PDF Virtual File (PVF) out of our data...
$pvf_filename = "/pvf/image/image1.jpg";
//and store the $MyImage data (picture data from above)
//    in it!
$p->create_pvf($pvf_filename,$MyImage, "");
//Load the image from the PVF into, er, uh, ram..., and, uh...
$image = $p->load_image("jpeg", $pvf_filename,"");
//Put it on the screen! :)
$p->fit_image($image, 100,500,"boxsize {100 100} position 50 fitmethod meet");
//Be cool and clean up after yourself...
$p->delete_pvf($pvf_filename);

//And... Render!
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=urlImageTest.pdf");
print
$buf;
?>
Nicolas Padfield nicolasatpadfielddotdk
10-Mar-2006 09:34
Example use of  PDF_load_image():

<?php
$pdf
= PDF_new();
PDF_open_file($pdf,'');
PDF_begin_page($pdf,595,842);
$image = PDF_load_image($pdf,"png","myimage.png","");
PDF_place_image($pdf,$image,64,26,.24);
?>

If you want something that is more free for commercial use, open source and does not require compiling, you could look at for example http://www.fpdf.org in stead of PDFlib

 
show source | credits | sitemap | contact | advertising | mirror sites