Replies: 3   Views: 3556
Adding a table of contents to a template
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by acunnington  · 18-04-2013 - 11:59

My question is: Is this possible?

I have an existing template file, which already contains a table of contents. However, each time to the document is created by PHPDocX, the table of contents remains the same. Is there some way that I can either:

a) Automatically update the existing table of contents after document creation?, or.

b) Add a table of contents to the document?

Many thanks.

Posted by mwtsoftware  · 25-04-2013 - 05:30

I have a document created using a template. I would like to insert or update a TOC after the document is completed. That way it could be converted to a PDF and emailed without manual intervention. Has anyone had success in doing this?

Posted by jorgelj  · 25-04-2013 - 09:18


TOC content is created by Word after you open a document because it's dynamic. If you use a Windows server you could run transformDocxUsingMSWord method that uses COM functions.

Or you could create a custom TOC using tables or lists. It won't be a real TOC but something similar.