PHP / FPDF: How to insert image at cell?

强颜欢笑 提交于 2020-01-25 04:17:13

问题


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

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');

Can anyone help me?


回答1:


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]]]]]])

Or:

$image1 = "img/image1.jpg";
 $this->Cell( 40, 40, $pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 33.78), 0, 0, 'L', false );

Edit you code:

$pdf->Cell(95,50,$pdf->MemImage(base64_decode($logo), 100, 50),1,0, 'C');


来源:https://stackoverflow.com/questions/59152232/php-fpdf-how-to-insert-image-at-cell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!