小编san*_*ita的帖子

使用TemplateProcessor在PHP.Word中添加图像

我不知道是否可以使用TemplateProcessor在PHPWord模板中添加图像.

我有一个文件(form.docx).该文档是一个模板.我阅读了字段(例如$ {name})并将其替换为文本.

$template = new TemplateProcessor('form.docx');
$template->setValue('name', $name);
Run Code Online (Sandbox Code Playgroud)

但现在,我想放一张图片,但我不知道我是怎么做的.我尝试这个:

$img='img.jpg';
$template->setValue('image',$img);
Run Code Online (Sandbox Code Playgroud)

不起作用.我尝试其他形式,创建一个部分并将此部分添加到模板但这失败了.

$phpWord = new PhpWord();
$section = $phpWord->createSection();   

$section->addImage('img.jpg', array('width'=>210, 'height'=>210, 'align'=>'center'));
$template = new TemplateProcessor('form.docx'); 
$template->setValue('image',$section).
Run Code Online (Sandbox Code Playgroud)

有人知道如何使用模板将图像放入.docx吗?

谢谢.

php docx phpword

5
推荐指数
1
解决办法
6732
查看次数

在Windows 7中失败的npm install命令weinre

我尝试使用命令安装weinre来调试一个phonegap应用程序:npm install weinre

我总是犯同样的错误:

npm命令

我使用Windows 7,我用管理员打开了cmd,我已经安装了node.js. 我已经阅读了有关此问题的其他问题,但我没有解决方案.

拜托,你能帮帮我吗?

node.js npm weinre

2
推荐指数
1
解决办法
919
查看次数

标签 统计

docx ×1

node.js ×1

npm ×1

php ×1

phpword ×1

weinre ×1