如何替换页脚中的占位符?



有这样的代码:

$templateProcessor = new TemplateProcessor('path to DOCX file.....');
$table = new Table(['unit' => TblWidth::AUTO]);
$table->addRow();
$table->addCell(null, [
'borderTopColor' => 'ff0000',
'borderTopSize' => 1,
'borderRightColor' => 'ff0000',
'borderRightSize' => 1,
'borderLeftColor' => 'ff0000',
'borderLeftSize' => 1,
])->addText('bla bla bla', ['Color' => 'ff0000']);
$templateProcessor->setComplexValue('{bla_bla_bla_placeholder}', $table);

问题是,如果{bla_bla_bla_placeholder}在页脚,它不会被替换,通过:$templateProcessor->setComplexValue('{bla_bla_bla_placeholder}', $table);

如果它在页面主体中,它将被替换为我期望的样子。

你能告诉我如何替换页脚中的占位符吗?.docx文件格式

我将回答我自己的问题。由于某种原因,我的占位符替换不能通过页脚中的$templateProcessor->setComplexValue工作。所以我在。docx文件中创建了一个表格在单元格中插入了占位符然后通过通常的替换占位符$templateProcessor->setValue甚至可以在header

中工作

最新更新