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

Updating TOC page numbers #951

Closed
sivaram-blr opened this issue Nov 23, 2016 · 18 comments · Fixed by #1205
Closed

Updating TOC page numbers #951

sivaram-blr opened this issue Nov 23, 2016 · 18 comments · Fixed by #1205

Comments

@sivaram-blr
Copy link

sivaram-blr commented Nov 23, 2016

Hello Team,

I am generating docx using template. I am dynamically updating few tables in template. So on each scenario table content may be short or long so total page numbers will differ on each document that gets created.

And list of headings(TOC items) remain always same, but their content will vary dynamically.

Now what is happening is when click one heading in TOC, it takes me to right position. But the page number in TOC is not matching with actual page number of that.

Note: addTOC function helps to add new TOC item. I am looking something like updateTOC to update the existing TOC items in TEMPLATE based on dynamic content i write.

So i am looking for help to "Update the page numbers" at just before end of document created.

Thanks


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@mattsagen
Copy link

Hi there I am dealing with something similar, and I am investigating Macros - all these things (bookmarks, titles, etc) are "Fields" - in Word you can set an option to "Update fields before printing" and "Update linked data before printing" - if the person doesn't have that set, then they either have to be updated manually or you can have a macro that runs at open or close...

@deepakgup
Copy link

@mattsagen Any luck solving this one?

@troosan
Copy link
Contributor

troosan commented Nov 25, 2017

maybe we should just implement http:https://www.datypic.com/sc/ooxml/e-w_updateFields-1.html

@troosan
Copy link
Contributor

troosan commented Nov 25, 2017

implemented in 0.14

@troosan troosan closed this as completed Nov 25, 2017
@deepakgup
Copy link

That was super fast. Thanks @troosan. Sry I am new to Git/hub how do I get hold of 0.14

Cheers!

@troosan
Copy link
Contributor

troosan commented Nov 25, 2017

@deepakgup you either wait for the final 0.14 version or you point to the development branch.
To do this you use version "dev-master"

@waghyogesh
Copy link

@sivaram-blr Hi, I am generating TOC in phpword doc but it dosent generating page numbers or indexing numbers ..can you please help out me on issue.

@fgali
Copy link

fgali commented Dec 27, 2017

Where can I get an example code on how to make a table of contents?

@troosan
Copy link
Contributor

troosan commented Dec 27, 2017

see answer to same question in #707

@brucelin0325
Copy link

brucelin0325 commented Jan 5, 2018

Hi @troosan
I like this library very much, I have a question, sample 17 (Title TOC) works fine on my local machine,
I mean addTOC and force update all fields when opening document.
But why it doesn't work on live domain? ( my custom toc doesn't update the fields )
I'm using office 2013 and it doesn't update when opening doc.
You can check it on this url.
http:https://www.thruline.com/intranet/CreateGridReport.php?v=20
Thanks in advance.

@troosan
Copy link
Contributor

troosan commented Jan 5, 2018

@brucelin0325
Indeed, when I open the document, the TOC is being updated, but the page numbers are hidden.
There is an issue because you are working with 2 columns. Somehow the page number is being hidden behind the second column. If you put it in 1 column the page numbers are shown.

FYI, your index can be built using XE and INDEX fields, see http:https://phpword.readthedocs.io/en/latest/elements.html#fields

@brucelin0325
Copy link

Really Thank you @troosan
I make a huge progress, I tried as 1 column TOC, and page numbers are shown since I update the document.
Current TOC looks something like this.

A SERIES OF UNFORTUNATE EVENTS, SEASON 3 ................6
GUESS WHO DIED ..........................................8
VALLEY OF THE BOOM ......................................10
AMERICAN VANDAL, SEASON 2 ...............................11
RUSSIAN DOLL ............................................12
THE OA, SEASON 2 ........................................13
....

My goal is create TOC looks like this one.
https://www.dropbox.com/s/36gx56p88auwm99/My%20Goal.png?dl=0

Can I add normal text section between TOC?
Can I rearrange the TOC?
Can I archieve this?

I'd appreciate if you can give me the solution.
I hope my questions help a little to enhance this library.
All the best.

@troosan
Copy link
Contributor

troosan commented Jan 8, 2018

@brucelin0325 That's not a TOC but an index (with XE (index entry) and INDEX fields.
Could you please open a question on StackOverFlow so we can continue this discussion there. It will benefit more people this way.

@fgali
Copy link

fgali commented Jan 8, 2018

Hello, I would like to know how to present special characters (<,>,> =, <=, among others) of correct way, I have tried several unsuccessfully.

@chaitanyagubbala
Copy link

Unable to display page numbers in TOC even after setting setUpdateFields as true.
Can you please someone help on this!

@jet-desk
Copy link
Contributor

jet-desk commented Jul 8, 2019

the same unable to display page numbers in TOC even after setting setUpdateFields as true

@pavarnos
Copy link

pavarnos commented Jul 11, 2019

same. if i call setUpdateFields(true) then every time i open the file (Mac) it asks This document contains fields that may refer to other files. Do you want to update the fields in this document? The page numbers do not appear.

@simogeo
Copy link

simogeo commented Feb 13, 2023

Ho, I'm using 0.18.3 version but still I'm not able to display page number in TOC, neither available in Word nor LibreOffice.

Could someone help me ?

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

Successfully merging a pull request may close this issue.