我在docx模板中有这个:
${evidence}
${date}
${image:720:480}
${/evidence}我试图在代码块中设置一个字符串和一个位于本地服务器上的映像,字符串被很好地替换,但是图像没有被插入,它只显示到图像的路径。
PHP代码:
$filepath = './uploads/image.png';
$replacements = array(
array('date' => '25-06-2022', 'image' => $filepath),
);
$templateProcessor->cloneBlock('evidence', 0, true, false, $replacements);在docx文件中输出:
25-06-2022
./uploads/image.png我使用的是PHPWord 0.18.3和PHP8.1。
发布于 2022-11-23 08:49:54
$templateProcessor->setImageValue('image', $filepath);
$templateProcessor->cloneBlock('evidence', 0, true, false, $replacements);支持图像替换:https://phpword-zh.readthedocs.io/zh_CN/latest/templates-processing.html
https://stackoverflow.com/questions/73000616
复制相似问题