alien alien - 3 years ago 152
PHP Question

fpdf display image in table row using table with multilcell

I am having trouble displaying image using fpdf library. I use fpdf Table with MultiCells scripts [ ].

I can display data by calling this function

$data = [
foreach($data as $v) $pdf->Row($v);

It will generate data nicely. I want to replace
with image . How can I display image using this script?

My pdf will be look like this.
enter image description here

Answer Source

Modify PDF_MC_Table class Row() functions by using Inhertence.

Class Pdf extends PDF_MC_Table{
  protected $imageKey = '';

  public function setImageKey($key){
    $this->imageKey = $key;

  public function Row($data){
        $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';

        //modify functions for image 
        if(!empty($this->imageKey) && in_array($i,$this->imageKey)){
          $ih = $h - 0.5;
          $iw = $w - 0.5;
          $ix = $x + 0.25;
          $iy = $y + 0.25;
          $this->MultiCell($w,5,$this->Image ($data[$i],$ix,$iy,$iw,$ih),0,$a);


Now call this function like this

$data = [

$pdf = new Pdf();
$pdf->setImageKey = [4];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download