Hello,
Sorry but we're unable to replicate the issue.
Please run this code standalone (using the classes from phpdocx without doing changes):
<?php
require_once 'classes/CreateDocx.inc';
$docx = new CreateDocxFromTemplate('TemplateWordFragmentsTarget.docx');
$numbering = new WordFragment($docx);
$options = [
'textAlign' => 'right',
'bold' => false,
'sz' => 14,
'color' => '000000'
];
$numbering->addPageNumber('numerical', $options);
$docx->replaceVariableByWordFragment(['VAR_HEADER_3' => $numbering], ['target' => 'header']);
$docx->replaceVariableByWordFragment(['VAR_FOOTER_2' => $numbering], ['target' => 'footer']);
$docx->createDocx('output');
You may find the TemplateWordFragmentsTarget.docx in the examples/files folder. Do you get the same error?
Regards.
PS we have changed your username to hide your email in the forum