phpword 无法替换 docx 文件中的现有图像
我正在尝试使用下面的代码替换word文件中的现有图像。当我保存输出文件时,它具有旧图像。
我打开 Word 文件并粘贴 1.png 图像,然后尝试将 1.png 替换为 2.jpg 但它没有执行任何操作。我尝试过很多解决方案,但没有找到任何永久的好的解决方案。
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($source_file);
$image_path = '2.jpg';
$templateProcessor->setImageValue('1.png', '2.jpg');
$templateProcessor->saveAs('output.docx');
版本“phpoffice/phpword”:“^0.18.3”
I am trying to replace existing image in the word file using below code. when I save the output file was having old image as it is.
I open the word file and paste the 1.png image then I try to replace 1.png with 2.jpg but it is not doing anything. I have tried to see many solutions but I do not found any permanent good solution.
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($source_file);
$image_path = '2.jpg';
$templateProcessor->setImageValue('1.png', '2.jpg');
$templateProcessor->saveAs('output.docx');
version "phpoffice/phpword": "^0.18.3"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论