Hi,
I want to update TOC (Table of content ) dynamically .How to refresh the TOC
some one can help me with code sample .
Last edited 19 June 2020
Hi,
I want to update TOC (Table of content ) dynamically .How to refresh the TOC
some one can help me with code sample .
Last edited 19 June 2020
Hi,
Thank you for your question. TOC is always rebuilt when generating PDF files via DocumentGenerator. If your output is Word (.docx) format, then TOC is not automatically rebuilt and you need to use the DOM APIs to rebuild the TOC. Could you please give me more details about what you are trying to achieve?
Best regards, Jure
Hi,
thank you for your response
I was trying on word (.docx) where we have table of contents it should be dynamically update based on the visibility of contents(table content -table header style -heading 1).
Can you help me how DOM APIs to rebuild the TOC with code in c#.(Update dynamic fields, such as Table Of Contents (TOC).
(Note:C# programmatically)
Regards Dhaneesh
Last edited 23 June 2020
Hi Dhaneesh,
Basically, what you need to do is: 1. Load the docx document using the Document.Load static method. 2. Save the loaded document using the Document.Save method.
See the snippet below:
Document document;
using (FileStream fileStream = File.Open(@"c:\InputWordDocument.docx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
document = Document.Load(fileStream);
}
// The Document.Save method also rebuilds TOC. You can use the Stream-based overload of this method.
document.Save(@"c:\ResultWordDocument.docx");
I hope this helps.
Regards, Jure
Last edited 15 September 2020