We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

About insert document

hi,

please refer to the document in the attachment.
how can i insert a document for every TOC list(“Heading 1”,“Heading 2” etc).

Best Regard!


Hi Liu,


Thanks for your inquiry. Every node of TOC field is represented by a HYPERLINK field. When you click on a TOC item, the control jumps to a particular location in your document pointed by a hidden Bookmark. I think, in your case, you can simply insert document inside those hidden Bookmarks as follows:

Document doc = new Document(MyDir + @“Source.doc”);

DocumentBuilder builder = new DocumentBuilder(doc);

foreach (Bookmark bm in doc.Range.Bookmarks)

{

if (bm.Name.StartsWith("_Toc"))

{

builder.MoveToBookmark(bm.Name, false, false);

// you can optionally check the style of the current paragraph and then insert document

}

}


I hope, this helps.

Best regards,