using System;
using System.Linq;
using SautinSoft.Document;
namespace Example
{
class Program
{
static void Main(string[] args)
{
TOC();
}
public static void TOC()
{
DocumentCore dc = new DocumentCore();
ParagraphStyle Heading1Style = (ParagraphStyle)Style.CreateStyle(StyleTemplateType.Heading1, dc);
dc.Styles.Add(Heading1Style);
ParagraphStyle Heading2Style = (ParagraphStyle)Style.CreateStyle(StyleTemplateType.Heading2, dc);
dc.Styles.Add(Heading2Style);
Section section = new Section(dc);
dc.Sections.Add(section);
section.Blocks.Add(new Paragraph(dc, "Table of Contents"));
section.Blocks.Add(new TableOfEntries(dc, FieldType.TOC));
section.Blocks.Add(new Paragraph(dc, "The end."));
section.Blocks.Add(
new Paragraph(dc,
new SpecialCharacter(dc, SpecialCharacterType.PageBreak)));
section.Blocks.Add(
new Paragraph(dc, "Chapter 1")
{
ParagraphFormat =
{
Style = Heading1Style
}
});
section.Blocks.Add(
new Paragraph(dc, String.Format("Subchapter 1-1"))
{
ParagraphFormat =
{
Style = Heading2Style
}
});
section.Blocks.Add(
new Paragraph(dc,
"«Document .Net» will help you in development of applications which operates with DOCX, RTF, PDF and Text documents. After adding of the reference to (SautinSoft.Document.dll) - it's 100% C# managed assembly you will be able to create a new document, parse an existing, modify anything what you want."));
section.Blocks.Add(
new Paragraph(dc,
new SpecialCharacter(dc, SpecialCharacterType.PageBreak)));
section.Blocks.Add(
new Paragraph(dc, "Chapter 2")
{
ParagraphFormat =
{
Style = Heading1Style
}
});
section.Blocks.Add(
new Paragraph(dc, String.Format("Subchapter 2-1"))
{
ParagraphFormat =
{
Style = Heading2Style
}
});
section.Blocks.Add(
new Paragraph(dc,
"Requires only .Net 4.0 or above. Our product is compatible with all .Net languages and supports all Operating Systems where .Net Framework can be used. Note that «Document .Net» is entirely written in managed C#, which makes it absolutely standalone and an independent library. Of course, No dependency on Microsoft Word."));
var toc = (TableOfEntries)dc.GetChildElements(true, ElementType.TableOfEntries).FirstOrDefault();
toc.Update();
dc.GetPaginator(new PaginatorOptions() { UpdateFields = true });
dc.Save("Table-Of-Contents.docx");
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("Table-Of-Contents.docx") { UseShellExecute = true });
}
}
}