5

I'm using https://github.com/PHPOffice/PHPWord to generate a word document. The function addTOC generates an index of pages with titles, but for some reason the page numbers do not display.

// add table of contents
$section->addTOC();

Results in:

Table of contents

If I echo the page numbers on the pages where the titles exist, they display fine. But they don't display in the TOC. I checked to confirm the text isn't white.

Geoff Maddock
  • 1,700
  • 3
  • 26
  • 47
  • I figured this out, the author name is troosan, he is on this stackoverflow. Btw check my answer below. – brucelin Sep 27 '18 at 21:25

1 Answers1

0

From PHPWord example in samples dir (https://github.com/PHPOffice/PHPWord/blob/develop/samples/Sample_17_TitleTOC.php), I would tell it is not possible:

echo date('H:i:s'), ' Note: Please refresh TOC manually.', EOL;

I also tried to add the TOC at the end of the document, after titles declarations (when we already know page numbers). But with no success.

EDIT: seems to be a bug: https://github.com/PHPOffice/PHPWord/issues/707

Worst
  • 169
  • 8