Class PageNumbers
Represents the page numbers in the Word document.
Implements
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.NET.dll
Syntax
public class PageNumbers : FormatBase, IXDLSSerializable
Examples
The following code example demonstrates how to chapter numbering in the document.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add the section into Word document
IWSection section = document.AddSection();
//Add the page number to document
section.PageSetup.PageStartingNumber = 1;
section.PageSetup.RestartPageNumbering = true;
section.PageSetup.PageNumberStyle = PageNumberStyle.Arabic;
//Specify the chapter number for heading 1
section.PageSetup.PageNumbers.HeadingLevelForChapter = HeadingLevel.Heading1;
//SPecify t he chapter number and page number separator
section.PageSetup.PageNumbers.ChapterPageSeparator = ChapterPageSeparatorType.Colon;
//Add a footer paragraph text to the document
IWParagraph paragraph = section.HeadersFooters.Footer.AddParagraph();
paragraph.ParagraphFormat.Tabs.AddTab(523f, TabJustification.Right, Syncfusion.DocIO.DLS.TabLeader.NoLeader);
//Add text for the footer paragraph
paragraph.AppendText("Copyright Northwind Inc. 2001 - 2024");
//Add page number field to the document
paragraph.AppendText("\tPage ");
paragraph.AppendField("Page", FieldType.FieldPage);
//Add the paragraph to the text body of the section
paragraph = section.AddParagraph();
paragraph.AppendText("First Title with Heading 1 Style");
//Apply Heading 1 built-in style
paragraph.ApplyStyle(BuiltinStyle.Heading1);
WParagraphStyle paraStyle = document.Styles.FindByName("Heading 1") as WParagraphStyle;
//Add the number format list for the Heading 1 style
paraStyle.ListFormat.ApplyDefNumberedStyle();
paraStyle.ListFormat.CurrentListLevel.PatternType = ListPatternType.UpLetter;
//Add the paragraph
paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum Turpis facilisis vitae consequat, cum a a,turpis dui consequat massa in dolor per, felis non amet.Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula");
//Add the page break
paragraph.AppendBreak(Syncfusion.DocIO.DLS.BreakType.PageBreak);
//Add the another paragraph to section
paragraph = section.AddParagraph();
paragraph.AppendText("Second Title with Heading 1 Style");
//Apply Heading 1 built-in style
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Add the paragraph
paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum Turpis facilisis vitae consequat, cum a a,turpis dui consequat massa in dolor per, felis non amet.Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula");
//Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add the section into Word document
Dim section As IWSection = document.AddSection()
'Add the page number to document
section.PageSetup.PageStartingNumber = 1
section.PageSetup.RestartPageNumbering = True
section.PageSetup.PageNumberStyle = PageNumberStyle.Arabic
'Specify the chapter number for heading 1
section.PageSetup.PageNumbers.HeadingLevelForChapter = HeadingLevel.Heading1
'SPecify t he chapter number and page number separator
section.PageSetup.PageNumbers.ChapterPageSeparator = ChapterPageSeparatorType.Colon
'Add a footer paragraph text to the document
Dim paragraph As IWParagraph = section.HeadersFooters.Footer.AddParagraph()
paragraph.ParagraphFormat.Tabs.AddTab(523F, TabJustification.Right, Syncfusion.DocIO.DLS.TabLeader.NoLeader)
'Add text for the footer paragraph
paragraph.AppendText("Copyright Northwind Inc. 2001 - 2024")
'Add page number field to the document
paragraph.AppendText(vbTab & "Page ")
paragraph.AppendField("Page", FieldType.FieldPage)
'Add the paragraph to the text body of the section
paragraph = section.AddParagraph()
paragraph.AppendText("First Title with Heading 1 Style")
'Apply Heading 1 built-in style
paragraph.ApplyStyle(BuiltinStyle.Heading1)
Dim paraStyle As WParagraphStyle = TryCast(document.Styles.FindByName("Heading 1"), WParagraphStyle)
'Add the number format list for the Heading 1 style
paraStyle.ListFormat.ApplyDefNumberedStyle()
paraStyle.ListFormat.CurrentListLevel.PatternType = ListPatternType.UpLetter
'Add the paragraph
paragraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum Turpis facilisis vitae consequat, cum a a,turpis dui consequat massa in dolor per, felis non amet.Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula")
'Add the page break
paragraph.AppendBreak(Syncfusion.DocIO.DLS.BreakType.PageBreak)
'Add the another paragraph to section
paragraph = section.AddParagraph()
paragraph.AppendText("Second Title with Heading 1 Style")
'Apply Heading 1 built-in style
paragraph.ApplyStyle(BuiltinStyle.Heading1)
'Add the paragraph
paragraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum Turpis facilisis vitae consequat, cum a a,turpis dui consequat massa in dolor per, felis non amet.Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula")
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
Constructors
PageNumbers()
Initializes a new instance of PageNumbers class.
Declaration
public PageNumbers()
Properties
ChapterPageSeparator
Gets or sets the separator between chapter number and page number.
Declaration
public ChapterPageSeparatorType ChapterPageSeparator { get; set; }
Property Value
Type | Description |
---|---|
ChapterPageSeparatorType | The ChapterPageSeparatorType member that specifies the numbering separator. |
HeadingLevelForChapter
Gets or sets the heading level to include chapter number along with page number.
Declaration
public HeadingLevel HeadingLevelForChapter { get; set; }
Property Value
Type | Description |
---|---|
HeadingLevel | The HeadingLevel member that specifies the heading level of the chapter. |
Methods
GetDefValue(Int32)
Return the default values for the property.
Declaration
protected override object GetDefValue(int key)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | key |
Returns
Type |
---|
System.Object |