0

When I use Phpword function addTOC, it is not displaying the page numbers.

// add table of contents
$section->addTOC();
ρss
  • 5,115
  • 8
  • 43
  • 73
  • why do you expect page numbers to be shown when you add a table of contents. Also please read http://stackoverflow.com/help/how-to-ask - your question not exactly verbose on what you do and try. – planetmaker Nov 05 '15 at 12:35
  • Duplicate question of http://stackoverflow.com/questions/33267654/phpword-addtoc-is-not-displaying-page-numbers/38995552 – Worst Aug 17 '16 at 12:02

1 Answers1

1

you need to include the following:

$phpWord->getSettings()->setUpdateFields(true);

this will prompt the user to update the ToC when they open the file (saving it will then store the page numbers)

Offbeatmammal
  • 7,970
  • 2
  • 33
  • 52