Hi everybody,
I want to insert a toc after the first page in my generated document.
How can I do that?
Thanks
//Open a blank word document as template
Document document = new Document();
//Get the first secition
Section section = document.AddSection();
//Create a new paragraph or get the first paragraph
Paragraph paragraph = section.AddParagraph();
//Append Text
paragraph.AppendText("Content");
paragraph = section.AddParagraph();
paragraph.AppendTOC(1, 4);
paragraph = section.AddParagraph();
paragraph.AppendBreak(BreakType.PageBreak);
foreach (BuiltinStyle builtinStyle in Enum.GetValues(typeof(BuiltinStyle)))
{
paragraph = section.AddParagraph();
//Append Text
paragraph.AppendText(builtinStyle.ToString());
//Apply Style
paragraph.ApplyStyle(builtinStyle);
}
//Save doc file.
document.SaveToFile("Sample.doc", FileFormat.Doc);
System.Diagnostics.Process.Start("Sample.doc");