【问题标题】:PHP / FPDF: How to insert image at cell?PHP / FPDF:如何在单元格中插入图像?
【发布时间】:2019-12-03 07:39:59
【问题描述】:

我想使用 FPDF 库将图像从 MySQL 显示为 PDF。我存储在 MySQL 中的图像是 BLOB。我已经成功显示图像。当前的代码会是这样的。

    $logo = $row['photo_before'];
    $pdf->MemImage(base64_decode($logo), 100, 50);

但是,我想如何将 $logo 放到单元格中?我当前的单元格代码如下:

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

谁能帮帮我?

【问题讨论】:

  • 去掉$logo周围的单引号。
  • 不能,出错

标签: php mysql fpdf


【解决方案1】:

你可以像这样创建一个单元格:

//Cell
Cell(float w [, float h [, string txt [, mixed border [, int ln [, string align [, 
boolean fill [, mixed link]]]]]]])

然后在相同位置创建图像:

//Image
 Image(string file [, float x [, float y [, float w [, float h [, string type [, mixed 
 link]]]]]])

或者:

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

编辑你的代码:

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

【讨论】:

  • 但我也使用 MemImage 库
  • is same answer replace $pdf->image with code of Memimage
  • 说真的我不明白。根据我上面的代码,你能编辑一下吗?
  • 还是不行,图片是按照(100,50)坐标的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-09-29
  • 2018-12-21
  • 2016-01-24
  • 2021-08-28
相关资源
最近更新 更多