在表单元格上的phpword addImage,在我的word.docx中显示空白图像

时间:2019-10-18 10:55:03

标签: php phpword phpoffice

当我在代码中添加图片时,它在我的办公室中显示空白图片。

$document_with_table = new \PhpOffice\PhpWord\PhpWord();
$section = $document_with_table->addSection();
$table = $section->addTable(array('align'=>'center'));
$table->addRow();

这是我的问题

$table->addCell(2000,$styleCell)->addImage('source_image.jpg'); 
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($document_with_table, 'Word2007');
$fullxml = $objWriter->getWriterPart('Document')->write();
$tablexml = preg_replace('/^[\s\S]*(<w:tbl\b.*<\/w:tbl>).*/', '$1', $fullxml);

$template_document = new \PhpOffice\PhpWord\TemplateProcessor(base_url('my_template.docx'));

$template_document->setValue('table', $tablexml);

0 个答案:

没有答案