I'm trying to replace a template variable with a pagenumber, but I'm getting a strange error (not what I would expect).
Stacktrace: https://s1.postimg.org/yhv6iiycd/Knipsel.png
From the docs:
// create a Word fragment to insert in the default header
$numbering = new WordFragment($docx, 'defaultHeader');
// set some formatting options
$options = array('textAlign' => 'right',
'bold' => true,
'sz' => 14,
'color' => 'B70000',
);
$numbering->addPageNumber('numerical', $options);
$docx->addHeader(array('default' => $numbering));
My implementation: (where $this is an instance of CreateDocxFromTemplate)
function addPageNumberingToDocument()
{
// create a Word fragment
$numbering = new WordFragment($this);
$options = [
'textAlign' => 'right',
'bold' => false,
'sz' => 14,
'color' => '000000'
];
$numbering->addPageNumber('numerical', $options);
// Replace variables(pagenumber) in header and footer
$this->replaceVariableByWordFragment(['pagenumber' => $numbering], ['target' => 'header']);
$this->replaceVariableByWordFragment(['pagenumber' => $numbering], ['target' => 'footer']);
}
How should I go about replacing a variable with a pagenumber?