Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any update for the page numbers missing issue of TOC ? #1691

Open
jiayuxiaochaoren opened this issue Aug 13, 2019 · 4 comments · May be fixed by #2556
Open

Is there any update for the page numbers missing issue of TOC ? #1691

jiayuxiaochaoren opened this issue Aug 13, 2019 · 4 comments · May be fixed by #2556

Comments

@jiayuxiaochaoren
Copy link

I use the version 0.16.0,but still has this question.

@mdupont
Copy link
Contributor

mdupont commented Sep 3, 2019

AFAIK just make sure to set $phpWord->getSettings()->setUpdateFields(true); and that the document is not in "protected" mode, and open the document in Word. A pop-up will open to ask you whether you want to update the document, agree. After Word updated the fields, the page numbers will display.

At the level of PHPWord, there is no way to know on which page the content will end up on, it is up to Word.

@jiayuxiaochaoren
Copy link
Author

Thank you for your reply.
but I still don't understand, why i can get titles of contents but can't get the nums of pages?

@cerw
Copy link

cerw commented Sep 17, 2021

Any solution to this?

@jgiacomello
Copy link

I've found a possible solution: just change in PhpWord/Writer/Word2007/Element/TOC.php the line 116 from

$xmlWriter->text("PAGEREF _Toc{$rId} \\h");

to

$xmlWriter->text("PAGEREF $rId \\h");

using $phpWord->getSettings()->setUpdateFields(true); it seems it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants