I have a docx document which is prefilled with certain texts and blocks. The document also contains a table of contents and all headings.
I edit the docx document with PHPWord Template Processor. Here, individual blocks are duplicated, deleted or texts are adapted. As a result, the headings no longer match the table of contents.
So I tried to recreate a table of contents with PHPWord, but unfortunately I couldn’t do it.
In the PHPWord documentation there is an option that tells Word to update the table of contents when the document is opened.
This is not enough for me, as the docx file is to be downloaded as a pdf before downloading. Therefore, the table of contents must be correct, as this cannot be updated beforehand by opening Word.
Is there a way to update the table of contents via PHP? It doesn’t matter which library or technology (as long as it works on a Linux server) is to be used. Updating directly during PDF export would also be sufficient.