PHP : Function Reference : PDF Functions : PDF_place_image
Examples ( Source code ) » PDF_place_image
<?php
//Create & Open PDF-Object
$pdf = pdf_new();
pdf_open_file($pdf);
pdf_set_info($pdf, "Author","Bob Nijman");
pdf_set_info($pdf, "Title","www.nijman.de");
pdf_set_info($pdf, "Creator", "bob@nijman.de");
pdf_set_info($pdf, "Subject", "pdf_open_image_file");
pdf_begin_page($pdf, 200, 200);
$pdfimage = pdf_open_image_file($pdf, "jpeg", "test.jpg");
pdf_place_image($pdf, $pdfimage, 10, 10, 0.6);
//close it up
pdf_end_page($pdf);
pdf_close($pdf);
$data = pdf_get_buffer($pdf);
header('Content-type: application/pdf');
header('Content-disposition: inline; filename=image.pdf');
header('Content-length: ' . strlen($data));
echo $data;
?>
bob
FYI:
There's a good reason for the fact that we need two functions
(pdf_open_image_file and pdf_place_image)
to insert an image.
This way we can use the same image more than once without having to store it in the PDF again.
admin
Contrary to the previous post, this function (pdf_place_image) is deprecated.
Use pdf_fit_image() instead. pdf_fit_image() takes the same parameters but read the PDFlib manual.
You should be using and reading the PDFlib manual along with the PHP manual to be current while writing your code.
To see all the internal functions available in the PDFlib try this:
$arr = get_defined_functions();
foreach(array_values($arr['internal']) as $arrVal){
if(strtolower(substr($arrVal,0,3))== "pdf") print($arrVal." ");
}
Please do your homework before posting a note that contradicts someone elses note.
stry_cat
bmironov at jonview dot com on 24-Jun-2003 03:58 said
> This function deprecated since PDFlib v5.0
I think you're confused. The depreciated function was pdf_put_image not pdf_place_image.
If this is also depreciated then we don't have any functions to add images to a PDF. Not a good thing.
|