Specifies the outline level of a paragraph in the document.
Namespace: SautinSoft.DocumentAssembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.11.20
Syntax Public Enumeration OutlineLevel
Members Member name | Value | Description |
---|
BodyText | 0 |
The paragraph is at the level of the main text.
|
Level1 | 1 |
The paragraph is at the outline level 1 (topmost level).
|
Level2 | 2 |
The paragraph is at the outline level 2.
|
Level3 | 3 |
The paragraph is at the outline level 3.
|
Level4 | 4 |
The paragraph is at the outline level 4.
|
Level5 | 5 |
The paragraph is at the outline level 5.
|
Level6 | 6 |
The paragraph is at the outline level 6.
|
Level7 | 7 |
The paragraph is at the outline level 7.
|
Level8 | 8 |
The paragraph is at the outline level 8.
|
Level9 | 9 |
The paragraph is at the outline level 9.
|
Example See Developer Guide: Create a document with table of content
Create a document with table of content using C#
using System;
using System.Linq;
using SautinSoft.Document;
namespace Example
{
class Sample
{
static void Main(string[] args)
{
ExtendedTOC();
}
public static void ExtendedTOC()
{
string resultFile = "Extended-Table-Of-Contents.docx";
DocumentCore dc = new DocumentCore();
ParagraphStyle Heading1Style = (ParagraphStyle)Style.CreateStyle(StyleTemplateType.Heading1, dc);
Heading1Style.ParagraphFormat.LineSpacing = 3;
Heading1Style.CharacterFormat.Size = 18;
Heading1Style.CharacterFormat.FontColor = new Color("#358CCB");
dc.Styles.Add(Heading1Style);
ParagraphStyle Heading2Style = (ParagraphStyle)Style.CreateStyle(StyleTemplateType.Heading2, dc);
Heading2Style.ParagraphFormat.LineSpacing = 2;
Heading2Style.CharacterFormat.Size = 14;
Heading2Style.CharacterFormat.FontColor = new Color("#FF9900");
dc.Styles.Add(Heading2Style);
ParagraphStyle TOCStyle = (ParagraphStyle)Style.CreateStyle(StyleTemplateType.Subtitle, dc);
TOCStyle.ParagraphFormat.OutlineLevel = OutlineLevel.BodyText;
TOCStyle.ParagraphFormat.Alignment = HorizontalAlignment.Center;
TOCStyle.CharacterFormat.Bold = true;
TOCStyle.CharacterFormat.FontColor = new Color("#358CCB");
dc.Styles.Add(TOCStyle);
Section section = new Section(dc);
dc.Sections.Add(section);
section.Blocks.Add(
new Paragraph(dc, "Table of Contents")
{ ParagraphFormat = { Style = TOCStyle } });
section.Blocks.Add(new TableOfEntries(dc, FieldType.TOC));
section.Blocks.Add(
new Paragraph(dc, "The End")
{ ParagraphFormat = { Alignment = HorizontalAlignment.Center, BackgroundColor = Color.Gray } });
section.Blocks.Add(
new Paragraph(dc, "Chapter 1")
{
ParagraphFormat =
{
Style = Heading1Style,
PageBreakBefore=true
}
});
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, HTML 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.")
{
ParagraphFormat = new ParagraphFormat
{
LeftIndentation = 10,
RightIndentation = 10,
SpecialIndentation = 20,
LineSpacing = 20,
LineSpacingRule = LineSpacingRule.Exactly,
SpaceBefore = 20,
SpaceAfter = 20
}
});
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.")
{
ParagraphFormat = new ParagraphFormat
{
LeftIndentation = 10,
RightIndentation = 10,
SpecialIndentation = 20,
LineSpacing = 20,
LineSpacingRule = LineSpacingRule.Exactly,
SpaceBefore = 20,
SpaceAfter = 20
}
});
var tableofcontents = (TableOfEntries)dc.GetChildElements(true, ElementType.TableOfEntries).FirstOrDefault();
tableofcontents.Update();
foreach (Paragraph par in tableofcontents.Entries)
{
par.ParagraphFormat.Style = TOCStyle;
}
dc.GetPaginator(new PaginatorOptions() { UpdateFields = true });
dc.Save(resultFile);
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(resultFile) { UseShellExecute = true });
}
}
}
Create a document with table of content using VB.Net
Option Infer On
Imports System
Imports System.Linq
Imports SautinSoft.Document
Module Sample
Sub Main()
ExtendedTOC()
End Sub
Sub ExtendedTOC()
Dim resultFile As String = "Extended-Table-Of-Contents.docx"
Dim dc As New DocumentCore()
Dim Heading1Style As ParagraphStyle = CType(Style.CreateStyle(StyleTemplateType.Heading1, dc), ParagraphStyle)
Heading1Style.ParagraphFormat.LineSpacing = 3
Heading1Style.CharacterFormat.Size = 18
Heading1Style.CharacterFormat.FontColor = New Color("#358CCB")
dc.Styles.Add(Heading1Style)
Dim Heading2Style As ParagraphStyle = CType(Style.CreateStyle(StyleTemplateType.Heading2, dc), ParagraphStyle)
Heading2Style.ParagraphFormat.LineSpacing = 2
Heading2Style.CharacterFormat.Size = 14
Heading2Style.CharacterFormat.FontColor = New Color("#FF9900")
dc.Styles.Add(Heading2Style)
Dim TOCStyle As ParagraphStyle = CType(Style.CreateStyle(StyleTemplateType.Subtitle, dc), ParagraphStyle)
TOCStyle.ParagraphFormat.OutlineLevel = OutlineLevel.BodyText
TOCStyle.ParagraphFormat.Alignment = HorizontalAlignment.Center
TOCStyle.CharacterFormat.Bold = True
TOCStyle.CharacterFormat.FontColor = New Color("#358CCB")
dc.Styles.Add(TOCStyle)
Dim section As New Section(dc)
dc.Sections.Add(section)
section.Blocks.Add(New Paragraph(dc, "Table of Contents") With {
.ParagraphFormat = New ParagraphFormat With {.Style = TOCStyle}
})
section.Blocks.Add(New TableOfEntries(dc, FieldType.TOC))
section.Blocks.Add(New Paragraph(dc, "The End") With {
.ParagraphFormat = New ParagraphFormat With {
.Alignment = HorizontalAlignment.Center,
.BackgroundColor = Color.Gray
}
})
section.Blocks.Add(New Paragraph(dc, "Chapter 1") With {
.ParagraphFormat = New ParagraphFormat With {
.Style = Heading1Style,
.PageBreakBefore = True
}
})
section.Blocks.Add(New Paragraph(dc, String.Format("Subchapter 1-1")) With {
.ParagraphFormat = New ParagraphFormat With {.Style = Heading2Style}
})
section.Blocks.Add(New Paragraph(dc, "�Document.Net� will help you in development of applications which operates with DOCX, RTF, PDF, HTML 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.") With {
.ParagraphFormat = New ParagraphFormat With {
.LeftIndentation = 10,
.RightIndentation = 10,
.SpecialIndentation = 20,
.LineSpacing = 20,
.LineSpacingRule = LineSpacingRule.Exactly,
.SpaceBefore = 20,
.SpaceAfter = 20
}
})
section.Blocks.Add(New Paragraph(dc, New SpecialCharacter(dc, SpecialCharacterType.PageBreak)))
section.Blocks.Add(New Paragraph(dc, "Chapter 2") With {
.ParagraphFormat = New ParagraphFormat With
{.Style = Heading1Style}
})
section.Blocks.Add(New Paragraph(dc, String.Format("Subchapter 2-1")) With {
.ParagraphFormat = New ParagraphFormat With {.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.") With {
.ParagraphFormat = New ParagraphFormat With {
.LeftIndentation = 10,
.RightIndentation = 10,
.SpecialIndentation = 20,
.LineSpacing = 20,
.LineSpacingRule = LineSpacingRule.Exactly,
.SpaceBefore = 20,
.SpaceAfter = 20
}
})
Dim tableofcontents = CType(dc.GetChildElements(True, ElementType.TableOfEntries).FirstOrDefault(), TableOfEntries)
tableofcontents.Update()
For Each par As Paragraph In tableofcontents.Entries
par.ParagraphFormat.Style = TOCStyle
Next par
dc.GetPaginator(New PaginatorOptions() With {.UpdateFields = True})
dc.Save(resultFile)
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(resultFile) With {.UseShellExecute = True})
End Sub
End Module
See Also