使用PHPword的Template可以实现 demo: $input_docx_name = 'input.docx'; $out_docx_name = 'out.docx'; $templateProcessor = new TemplateProcessor($input_docx_name); $templateProcessor->setValue('c_code', '22332233'); $templateProcessor->setImageValue('image', ['path' => 'z.png', 'width' => 159, 'height' => 159, 'ratio' => true]); $templateProcessor->saveAs($out_docx_name);
使用PHPword的Template可以实现
demo: