TemplateProcessor を使用して、PHPWord でテンプレートに画像を追加できるかどうかはわかりません。
ドキュメント (form.docx) があります。このドキュメントはテンプレートです。フィールド (たとえば ${name}) を読み取り、テキストに置き換えます。
$template = new TemplateProcessor('form.docx');
$template->setValue('name', $name);
でも今、画像を載せたいのですが、やり方がわかりません。私はこれを試します:
$img='img.jpg';
$template->setValue('image',$img);
動作しません。他のフォームを試して、セクションを作成し、このセクションをテンプレートに追加しますが、失敗します。
$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).
テンプレートを使用して .docx に画像を配置する方法を知っている人はいますか?
ありがとう。