hi,
i have created a pdffile dynamically.its working fine. means pdf file is creating automatically and data is coming form the database.now in that file iam trying to display the image from the database using the predefined funtions.first i tried with a static image. while i tried to run that file it is saying that undefined functions or
[B]
Fatal error: Uncaught exception ‘PDFlibException’ with message ‘pdf_open_image_file() expects exactly 5 parameters, 3 given’ in D:xampphtdocsiphonetest.php:70 Stack trace: #0 D:xampphtdocsiphonetest.php(70): pdf_open_image_file() #1 {main} thrown in D:xampphtdocsiphonetest.php on line 70
below is my code:
<?php
$pdf = pdf_new();
pdf_open_file($pdf,”c:invoice4.pdf”);
pdf_set_info($pdf, “Author”, “Uwe Steinmann”);
pdf_set_info($pdf, “Title”, “Test for PHP wrapper of PDFlib 2.0”);
pdf_set_info($pdf, “Creator”, “See Author”);
pdf_set_info($pdf, “Subject”, “Testing”);
pdf_set_parameter($pdf, “SearchPath”, “./”);
pdf_set_parameter($pdf, “hypertextencoding”, “winansi”);
pdf_set_parameter($pdf, “imagewarning”, “false”);
pdf_begin_page($pdf, 595, 842);
$font = PDF_load_font($pdf, “Courier”,”iso8859-1″, “”);
pdf_setfont($pdf, $font, 10);
// Gathering Mysql User Information
$con=mysql_connect(“localhost”,”root”,””);
$db=mysql_select_db(“test”);
$sql=”select * from pdf”;
$res=mysql_query($sql,$con);
//echo $res;
while($row=mysql_fetch_array($res))
{
// Colour coding
function hex2rgb($hex)
{
$color = str_replace(‘#’,”,$hex);
$rgb = array(‘r’ => hexdec(substr($color,0,2)),
‘g’ => hexdec(substr($color,2,2)),
‘b’ => hexdec(substr($color,4,2)));
return $rgb;
}
function rgb2cmyk($var1,$g=0,$b=0)
{
if(is_array($var1))
{
$r = $var1[‘r’];
$g = $var1[‘g’];
$b = $var1[‘b’];
}
else $r=$var1;
$cyan = 255 – $r;
$magenta = 255 – $g;
$yellow = 255 – $b;
$black = min($cyan, $magenta, $yellow);
$cyan = @(($cyan – $black) / (255 – $black)) * 255;
$magenta = @(($magenta – $black) / (255 – $black)) * 255;
$yellow = @(($yellow – $black) / (255 – $black)) * 255;
return array(‘c’ => $cyan / 255,
‘m’ => $magenta / 255,
‘y’ => $yellow / 255,
‘k’ => $black / 255);
}
// place a logo in the top left corner ($pdf, “jpeg”, “foto.jpg”, “”, 0)
$im = pdf_open_image_file($pdf, “jpeg”, “001.jpg”); // Assign image to variable
pdf_place_image($pdf, $im, 100, 300, 1); // Place image
pdf_close_image($pdf, $im); // close image
//pdf_show_xy($pdf, $row[‘logo’], 100, 800);
pdf_show_xy($pdf, $row[‘company’], 100, 800);
pdf_show_xy($pdf, $row[‘comp_addr’], 100, 780);
pdf_show_xy($pdf, “Invoice # :”.$row[‘invoiceid’], 400, 800);
pdf_show_xy($pdf, “Invoice Date :”.$row[‘date’], 400, 780);
pdf_show_xy($pdf, “Invoice Terms :”.$row[‘invoice_terms’].” Days”, 400, 760);
pdf_show_xy($pdf, “Bill To : ” , 100, 750);
// draw a line under the logo
pdf_moveto($pdf, 100, 745);
pdf_lineto($pdf, 143, 745);
pdf_stroke($pdf);
pdf_show_xy($pdf, $row[‘cname’], 95, 720);
pdf_show_xy($pdf, $row[‘address1’], 95, 700);
pdf_show_xy($pdf, $row[‘address2’], 95, 680);
pdf_show_xy($pdf, $row[‘city’], 95, 660);
pdf_show_xy($pdf, $row[‘state’], 95, 640);
pdf_show_xy($pdf, $row[‘zip’], 100, 620);
pdf_show_xy($pdf, “Details : ” , 100, 590);
// draw a line under the logo
pdf_moveto($pdf, 100, 585);
pdf_lineto($pdf, 140, 585);
pdf_stroke($pdf);
pdf_show_xy($pdf, “Date ” , 100, 570);
pdf_show_xy($pdf, “Activity ” , 170, 570);
pdf_show_xy($pdf, “Rate ” , 380, 570);
pdf_show_xy($pdf, “Hours ” , 430, 570);
pdf_show_xy($pdf, “Amount ” , 480, 570);
// draw a line under the logo
pdf_moveto($pdf, 100, 560);
pdf_lineto($pdf, 520, 560);
pdf_stroke($pdf);
pdf_show_xy($pdf, $row[‘date’], 93, 545);
pdf_show_xy($pdf, $row[‘project’], 170, 545);
pdf_show_xy($pdf, $row[‘description’], 170, 528);
pdf_show_xy($pdf, $row[‘rate’], 380, 545);
pdf_show_xy($pdf, $row[‘duration’], 430, 545);
pdf_show_xy($pdf, $row[‘amount’], 480, 545);
// draw a line under the logo
pdf_moveto($pdf, 100, 520);
pdf_lineto($pdf, 520, 520);
pdf_stroke($pdf);
$color=rgb2cmyk(hex2rgb(‘#FF0000’));
pdf_setcolor($pdf, “both”, “cmyk”, $color[‘c’], $color[‘m’], $color[‘y’], $color[‘k’]);
pdf_show_xy($pdf, “TOTAL: ” , 435, 500);
pdf_show_xy($pdf, “$”.$row[‘amount’], 480, 500);
}
pdf_end_page($pdf);
pdf_close($pdf);
?>
please give me the solution for placing the image in that pdf file.dynamically . waiting for your reply.
Thanks.