I have a word document that i use as template. the resulting Word document must have a table of contents, and so I have it in the template as: { TOC \o "1-2" \h \z }
When Aspose.Word loads this template from disc, it stops with : cannot interpret nested fields and crashes on -> Document mainDoc = word.Open("WordTest.doc");
Maybe it’s better if the component would just ignore the TOC codes, and pass these blocks unmodified on to the final resulting document?
This way, I don’t have to explain to my customers why they can’t have a TOC in their documents.
We are now working to support TOC in the documents. This requires implementing support for bookmarks and nested fields which are often requested features by themselves.
The best we can do is to let Aspose.Word pass TOC unmodified into the output document as discussed in the previous topics.
Please note that if you mail merged or otherwise manipulated content of the document, Aspose.Word will not update the TOC. It is up to MS Word to update the TOC field. When the fields in the document are updated depends on the user settings, they can be updated on open, on print or manually. This means that the user might see not up to date TOC at times depending on the settings and might need to refresh the field. Is this okay with you?
We have just released a version that supports bookmarks. This is about half way through to support TOC fields because TOC fields use bookmarks and nested fields. We are now going to implement support for nested fields.
I have succesfully imported a word document with a TOC now.
Next thing to do for me is finding a way on how to add my TOC fields to the document. The purpose of this is to make a nice reports.
This is interesting. All I need to do is allow adding bookmarks and fields to the document using DocumentBuilder. This is something we wanted to do anyway so maybe we can bring this work forward. I will keep you posted.
Thanks for your effort ! I tested the insertableofcontents method. and it works fine. But for my situation it’s not much use. I load a word document with an existing TOC, and add many chapters of text. Each chapter has many paragraph styles, of which the headings are collected by the TOC. I can do this now in an awkward matter with many predifined fields. But it would be so much nicer if I were able to add a text with stylenames … from code
But I haven’t found a way to use existing styles from code.
No worries, we were going to allow specifying styles using DocumentBuilder too. It will be something like DocumentBuilder.ParagraphFormat.Style = “MyStyle”.
Do you need to be able to create styles programmatically? This can also be done, but we probably want to do this later.
This is great I will only use the styles from the template documents. And of those the most important ones are “normal” and “heading1”, “heading2”. The headings are then collected by Word to make a nice TOC.
I tested the new styles property. and it works like a charm Now I can fully comply with my clients wishes. And do it faster and easier than any other method for making Word files.
If my project proposal is agreed upon, we will choose your components.
I want to create the TOC programatically in word document using ASP.NET. Can someone has any info on this. Is any of the ASPOSE component support this.
I got to generate pocket booklet with (Table of Content)TOC . booklet layout will be 8 pages per A4 size paper.
Aspose Reporting Serivces support this feature ? If so, we are willingly to buy the product .
If you need to generate the document from an RDL report, then this product is right what you need. To insert a TOC, specify “TOC” as the textbox ToolTip property value. Note this feature is undocumented.