Hi
ist it possible to insert a pagebreak inside a processed document?
thanks!
Alex
Can you try the following?
in you word document, put
${pageBreakHere}
Then run:
Settings::setOutputEscapingEnabled(false); //important, otherwise the XML will be written as is in the word document
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/template.docx');
$templateProcessor->setValue('pageBreakHere', '<w:p><w:r><w:br w:type="page"/></w:r></w:p>');
$templateProcessor->saveAs('results/generated_templateFile.docx');
This is not working for me. Can anyone confirm that it is working?
@SalvatorePollaci this worked for me.
PHP 7.0
phpoffice/phpword current (dev-master)
It's only working when opening on Word, not LibreOffice...
May be using xml is simplier than using the library...
I've found your solution working also on OpenOffice.
First you need to close previous text tag and reopen new row in the same paragraph with page break:
$templateProcessor->setValue('PAGE_BREAK', ''.'
. '
Not worked for me please can you share with more detail
getting error with [ Settings::setOutputEscapingEnabled(false); ] this line
Most helpful comment
I've found your solution working also on OpenOffice.
First you need to close previous text tag and reopen new row in the same paragraph with page break: '');
$templateProcessor->setValue('PAGE_BREAK', ''.'
. '