1

Using PHPOffice/PHPWord, I'd like to format the page numbers in my footer so that the numbers are bold, and rest of the text is plain, like this:

Page 3 of 10

At the moment I've got:

$footer->addPreserveText('Page {PAGE} of {SECTIONPAGES}', 'footerFont', 'footerPara');

Which works absolutely fine, except it'll only let me style the whole sentence, not the individual numbers.

I've tried using a textRun to break up the styling, but I get this error:

"Cannot add PreserveText in TextRun"

A textRun, on static text, works find in the footer; I can add to it using addText but NOT using addPreserveText.

How can I style my page numbers differently from the surrounding text so that I get bold numbers like in "Page 2 of 5"?

This question could take another route: "Is it possible to add page/section numbers using addText rather than addPreserveText?"

I have phpword version: 0.17.0 installed

Nicolas Goosen
  • 583
  • 5
  • 14

0 Answers0