首页 > 解决方案 > 带图像的 FPDF mc 表

问题描述

我无法使用 mc table FPDF 显示图像(或者这次是照片)。

这是我的一小部分脚本:

$pdf=new PDF_MC_Table();
$pdf->SetWidths(array(30,10,30,230));
$pdf->SetAligns(array('L','L','L','C'));
$pdf->Row(array($name, $age, $gender, $photo));
$pdf->Output();

$photo填写我想在我的 PDF 表格中显示的图像的位置。

该图像根本不显示,而是显示该位置的文本

标签: phpfpdf

解决方案


我已经得到了答案

在 mc_table.php 我添加了这个

...
function Row($data)
{
  ...
  for($i=0;$i<count($data);$i++)
  {
    ...
    if(substr($data[$i],-3) == 'jpg' || substr($data[$i],-3) == 'png')
    {
      $ih = $h - 0.5;
      $iw = $w - 0.5;
      $ix = $x + 0.25;
      $iy = $y + 0.25;
      //show image
      $this->MultiCell($w,5,$this->Image ($data[$i],$ix,$iy,$iw),0,$a);
    }else
    {
      //Print the text
      $this->MultiCell($w,5,$data[$i],0,$a);
    }
  ...
  }
}

推荐阅读