我有一个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');