2 posts, 0 answers
  1. Martin
    Martin avatar
    9 posts
    Member since:
    Mar 2015

    Posted 19 Mar 2015 Link to this post

    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? 
  2. Petya
    Petya avatar
    989 posts

    Posted 23 Mar 2015 Link to this post

    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.

Back to Top