PHP/FPDF:如何在单元格中插入图像? [英] PHP / FPDF: How to insert image at cell?
本文介绍了PHP/FPDF:如何在单元格中插入图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用FPDF库从MySQL到PDF显示图像.我存储在MySQL中的图像是BLOB.我已经成功地显示了图像.当前代码将是这样.
I want to display image from MySQL to PDF using FPDF library. the image that i stored in MySQL is BLOB. I already success to display the image. The current code will be like this.
$logo = $row['photo_before'];
$pdf->MemImage(base64_decode($logo), 100, 50);
但是,我想如何将$ logo放置到单元格中?我当前的单元格代码如下:
But, how I want to put the $logo to a cell? My current code for the cell as below:
$pdf->Cell(95,50,'$logo',1,0, 'C');
有人可以帮助我吗?
推荐答案
您可以创建一个像这样的单元格:
You can create a cell like:
//Cell
Cell(float w [, float h [, string txt [, mixed border [, int ln [, string align [,
boolean fill [, mixed link]]]]]]])
然后在相同位置创建图像:
Then create image in same position:
//Image
Image(string file [, float x [, float y [, float w [, float h [, string type [, mixed
link]]]]]])
或者:
$image1 = "img/image1.jpg";
$this->Cell( 40, 40, $pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 33.78), 0, 0, 'L', false );
编辑您的代码:
$pdf->Cell(95,50,$pdf->MemImage(base64_decode($logo), 100, 50),1,0, 'C');
这篇关于PHP/FPDF:如何在单元格中插入图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文