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

Table of Contents pagenumbers not displaying on Windows/office #1396

Open
1 of 2 tasks
thechib12 opened this issue Jun 1, 2018 · 4 comments
Open
1 of 2 tasks

Table of Contents pagenumbers not displaying on Windows/office #1396

thechib12 opened this issue Jun 1, 2018 · 4 comments

Comments

@thechib12
Copy link

thechib12 commented Jun 1, 2018

This is:

  • a bug report
  • a feature request

Expected Behavior

My word export generates a Table of Contents, with clickable links which point to the correct title. However, the page numbers are not displayed in the table of contents.

<?php
 $this->getSettings()->setUpdateFields(true);

Update field setting is set, and after applying this word will query for missing links. Still, no numbers are shown. This works for OSX and office for mac, so it appears to be a program/os related issue.

Update 8-06: The protected mode of a word document seems to cause this issue. If a word document is protected, and you need to switch it manually to edit mode the table of contents numbers are not updated.

Context

  • PHP version:5.3.18
  • PHPWord version: 0.14
@chaitanyagubbala
Copy link

I'm also facing the same issue.

@dennisvandenende
Copy link

I do have the same issue, but i noticed that the behaviour can be different on different word versions.
In all cases the TOC is not accurate with the pages.

@CyferZ
Copy link

CyferZ commented Feb 16, 2023

This still seems to be an issue. Quite a curious issue.

@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
Labels
None yet
Development

No branches or pull requests

5 participants