note 73831 added to function.pdf-load-image

From: Date: Mon, 12 Mar 2007 14:27:04 +0000
Subject: note 73831 added to function.pdf-load-image
Groups: php.notes 
Request: Send a blank email to php-notes+get-124375@lists.php.net to get a copy of this message
I've had a difficult time trying to load images to the pdf with pdflib, and tried many examples. I came across this one and it actually works for me in IE and Firefox. I hope this can be of some help to someone. <?php $searchpath = "path/to/image/dir"; $p = new PDFlib(); $p->set_parameter("errorpolicy", "return"); // check return values of load_font() etc. $p->set_parameter("hypertextencoding", "winansi"); // used to prevent problems with japanese systems $p->set_parameter("SearchPath", $searchpath); // **set search path parameter in pdf if ($p->begin_document("", "") == 0) { die("Error: " . $p->get_errmsg()); } $p->set_info("Creator", " the creator"); $p->set_info("Author", " you "); $p->set_info("Title", " imageInsert "); $p->begin_page_ext(612, 792, ""); // declare page with standard letter size $certLogo = "stamp.jpg"; // your image name $image = $p->load_image("auto", $certLogo, ""); if (!$image) { die("Error: " . $p->get_errmsg()); } $p->fit_image($image, 390,575, ""); //place image within page coordinates $p->close_image($image); // close resource $p->end_page_ext(""); $p->end_document(""); $data = $p->get_buffer(); $len = strlen($data); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=hello.pdf"); print $data; $p = 0; ?> ---- Server IP: 69.147.83.197 Probable Submitter: 72.39.97.24 ---- Manual Page -- http://www.php.net/manual/en/function.pdf-load-image.php Edit -- https://master.php.net/note/edit/73831 Del: integrated -- https://master.php.net/note/delete/73831/integrated Del: useless -- https://master.php.net/note/delete/73831/useless Del: bad code -- https://master.php.net/note/delete/73831/bad+code Del: spam -- https://master.php.net/note/delete/73831/spam Del: non-english -- https://master.php.net/note/delete/73831/non-english Del: in docs -- https://master.php.net/note/delete/73831/in+docs Del: other reasons-- https://master.php.net/note/delete/73831 Reject -- https://master.php.net/note/reject/73831 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124375) next »