I want to replace the variable (test_var) inside the document, i can create a table and add texts to it with addText, but the addImage method is not adding the image.
Here is my code:
$template = new PhpOfficePhpWordTemplateProcessor("test.docx");
$table = new PhpOfficePhpWordElementTable();
$table->addRow();
$table->addCell()->addText("test");
$table->addCell()->addImage("test.png");
$template->setComplexBlock('table_var', $table);
$template->saveAs("test_.docx");
- PHP version: 7.4
- PhpWord version: 0.17.0
2
Answers
Specify the absolute path to the file and everything will work
I added a new key and used it later to add the image. Worked perfectly.
Good luck!