Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用fpdf以PDF格式显示图像_Php_Image_Pdf_Fpdf - Fatal编程技术网

Php 使用fpdf以PDF格式显示图像

Php 使用fpdf以PDF格式显示图像,php,image,pdf,fpdf,Php,Image,Pdf,Fpdf,我想在创建的PDF文件中插入图像。然而,它的位置一点也不好 如果我这样做: $fpdf->Image($row_products['prod_imagelarge'], 10); $fpdf->Image($row_products['prod_imagelarge'],30, 40, 40, 40); 图像将出现,但是,它们太大了 如果我这样做: $fpdf->Image($row_products['prod_imagelarge'], 10); $fpdf-&g

我想在创建的PDF文件中插入图像。然而,它的位置一点也不好

如果我这样做:

$fpdf->Image($row_products['prod_imagelarge'], 10); 
$fpdf->Image($row_products['prod_imagelarge'],30, 40, 40, 40);
图像将出现,但是,它们太大了

如果我这样做:

$fpdf->Image($row_products['prod_imagelarge'], 10); 
$fpdf->Image($row_products['prod_imagelarge'],30, 40, 40, 40);
并非所有图像都将显示。每页仅显示1个图像,但带有 大小合适

实际上,我在while循环中插入了一个图像。 我想在pdf文件中显示的是:(按顺序)


如果一个页面包含多个图像,则可能是您的图像彼此重叠。您应该更改一页上每个图像的位置。试试这样的

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

与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);
}