Hello.
I create a document with library (CreateDocx()) . I create a footer in it. Then I insert content from the template. After saving the document, the footer is not showed. I also tried loading a document from a template and inserting a footer in it. But the footer is not showed. I did all these actions through method addFooterSection and addFooter. The result is negative. The code is taken from the example. I can attach the docx file, let me know where.
require_once 'phpdocx/classes/CreateDocx.php';
$docx = new \CreateDocxFromTemplate('agreement.docx');
$docx->removeFooters();
$footerTextFirstSection = new WordFragment($docx, 'firstFooter');
$footerTextFirstSection->addText('Footer in the first section');
// create a Word fragment with an image to be inserted in the footer of the document
$imageOptions = array(
'src' => 'tops.jpg',
'dpi' => 300,
);
$footerImageFirstSection = new WordFragment($docx, 'defaultFooter');
$footerImageFirstSection->addImage($imageOptions);
// by default, addFooterSection adds footers into the last section
$docx->addFooterSection(array('first' => $footerTextFirstSection, 'default' => $footerImageFirstSection));
// create a new section
$docx->addSection();
// add footers into the new section
// contents with dependencies such as images and links share the same internal header/footer scope for all sections in phpdocx.
// These contents must be created and added in order when adding headers and footers per section
$footerTextSecondSection = new WordFragment($docx, 'firstFooter');
$footerTextSecondSection->addText('Footer in the second section');
$footerContentSecondSection = new WordFragment($docx, 'defaultFooter');
$imageOptions = array(
'src' => 'tops.jpg',
'dpi' => 300,
'textWrap' => 1,
);
$footerContentSecondSection->addImage($imageOptions);
// add a page numbering
$style = array(
'bold' => true,
'color' => 'B70000',
'fontSize' => 24,
);
// create a custom style
$docx->createParagraphStyle('pgStyle', $style);
// set some formatting options
$options = array(
'textAlign' => 'right',
'pStyle' => 'pgStyle',
);
$footerContentSecondSection->addPageNumber('numerical', $options);
$footerContentSecondSection->addBreak();
// by default, addFooterSection adds the footers into the last section
$docx->addFooterSection(array('first' => $footerTextSecondSection, 'default' => $footerContentSecondSection));
$docx->createDocx('output');