This is a migrated thread and some comments may be shown as answers.

WordProcessing

1 Answer 82 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
DF
Top achievements
Rank 1
DF asked on 19 Mar 2015, 06:43 PM
Is it possible to using a RadFlowDocument to build a Word document with several sections from various html files, and then also to build a table of contents with the page numbers of each section? 

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 23 Mar 2015, 09:11 AM
Hello Martin,

The scenario is possible, although you should be aware RadWordsProcessing doesn't genuinely support table of content fields at this point. This means that you can add the field in the document, but you'd need to count on the consumer (e.g. MS Word or another viewer supporting DOCX documents) to update the field to its result.

As to the steps you need to execute, here is what I would suggest:
1. Import each HTML fragment with the HtmlFormatProvider. This would produce a RadFlowDocument instance.
2. Merge the documents with the Merge() method. By default this appends them together in separate sections and allows some additional handling of the styles.
3. Insert a TOC field through the approach explained in the CustomCodeField article. Make sure to set the IsDirty property to true, since it is the one that specifies the viewer should update the field.
4. Export to DOCX through DocxFormatProvider.

I hope this is useful.

Regards,
Petya
Telerik
Tags
General Discussions
Asked by
DF
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or