【问题标题】:PhpWord add image to table cellPhpWord 将图像添加到表格单元格
【发布时间】:2021-01-24 13:14:25
【问题描述】:

我想替换文档中的变量(test_var),我可以创建一个表格并用addText向其中添加文本,但是addImage方法没有添加图像。

这是我的代码:

$template = new \PhpOffice\PhpWord\TemplateProcessor("test.docx");

$table = new \PhpOffice\PhpWord\Element\Table();

$table->addRow();
$table->addCell()->addText("test");
$table->addCell()->addImage("test.png");

$template->setComplexBlock('table_var', $table);

$template->saveAs("test_.docx");
  • PHP 版本:7.4
  • PhpWord 版本:0.17.0

【问题讨论】:

  • 你确定路径正确吗?
  • @SimoneRossaini 是的,它只是添加一个空图像。

标签: php image phpword


【解决方案1】:

指定文件的绝对路径,一切正常

【讨论】:

猜你喜欢
  • 2011-07-09
  • 2011-09-10
  • 1970-01-01
  • 2014-07-11
  • 2011-08-17
  • 2015-11-09
  • 2019-01-02
  • 1970-01-01
  • 2023-03-03
相关资源
最近更新 更多