Radamel Falcao
Radamel Falcao

Reputation: 105

PHP / FPDF: How to insert image at cell?

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?

Upvotes: 1

Views: 3478

Answers (1)

Simone Rossaini
Simone Rossaini

Reputation: 8162

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

Upvotes: 1

Related Questions