Display pdf image using fpdf

I want to paste an image into my pdf file. However, he will not position at all.

If I do this:

$fpdf->Image($row_products['prod_imagelarge'], 10); 

Images will be displayed, however they are too large.

If I do this:

$fpdf->Image($row_products['prod_imagelarge'],30, 40, 40, 40);

Not all images will appear. Only 1 image per page is displayed, but with the correct size.

In fact, I am inserting an image inside a while loop. What I would like to display in a pdf file: (in order)

-product name (works fine)  
-product image (the problem is here!)  
-product description (works fine)
+5
source share
2 answers

Naveed, , . , X Y , ( "" ) , .

$image_height = 40;
$image_width = 40;
while ($row_products = mysql_fetch_array($products)) { 
   $fpdf->Cell(0, 0, $row_products['prod_name'], 0, 2);
   $fpdf->Cell(0, 0, $row_products['prod_description'], 0, 2);

   // get current X and Y
   $start_x = $fpdf->GetX();
   $start_y = $fpdf->GetY();

   // place image and move cursor to proper place. "+ 5" added for buffer
   $fpdf->Image($row_products['prod_imagelarge'], $fpdf->GetX(), $fpdf->GetY() + 5, 
                $image_height, $image_width) 
   $fpdf->SetXY($start_x, $start_y + $image_height + 5);
}
+7

, . . - .

for( $i=10; $i<=200; $i=$i+10 ) {
  $fpdf->Image($row_products['prod_imagelarge'],30, $i, 40, 40);
}
+5

All Articles