如何在PhpWord中用templateProcessor替换页眉/页脚值?

我有一个docx模板,我想使用templateProccessor更改页眉和页脚的值。我已经用简单的文本完成了此操作,但是我不知道如何针对页眉和页脚进行操作。

这是我的代码:

    // Creating the new document...
    $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('../Template.docx');

    //Set headers and footers


    //set value
    $templateProcessor->setvalue('title','Test');

    //Triplicate block
    $templateProcessor->cloneBlock('firstblock',3,true,true);
    $templateProcessor->setvalue('firstname#1','John');
    $templateProcessor->setvalue('lastname#1','Doe');
    $templateProcessor->setvalue('firstname#2','John');
    $templateProcessor->setvalue('lastname#2','Doe');
    $templateProcessor->setvalue('firstname#3','John');
    $templateProcessor->setvalue('lastname#3','Doe');
    //Set image
    $templateProcessor->setImageValue('logo',array('path' => '../img/logo.png','width' => 100,'height' => 100));
    $templateProcessor->saveAs('test.docx');
caindeck 回答:如何在PhpWord中用templateProcessor替换页眉/页脚值?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3166248.html

大家都在问