问题
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