Class WPageSetup
Represents the page setup description.
Implements
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class WPageSetup : FormatBase, IXDLSSerializable
Examples
The following code example demonstrates how to set the page setup properties.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
//Set page setup options
section.PageSetup.Orientation = PageOrientation.Landscape;
section.PageSetup.Margins.All = 72;
section.PageSetup.Borders.LineWidth = 2;
section.PageSetup.DifferentFirstPage = true;
section.PageSetup.DifferentOddAndEvenPages = true;
section.PageSetup.FooterDistance = 42;
section.PageSetup.HeaderDistance = 52;
section.PageSetup.LineNumberingDistanceFromText = 10;
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous;
section.PageSetup.LineNumberingStartValue = 5;
section.PageSetup.LineNumberingStep = 2;
section.PageSetup.PageBorderOffsetFrom = PageBorderOffsetFrom.Text;
section.PageSetup.PageBordersApplyType = PageBordersApplyType.AllPages;
section.PageSetup.PageNumberStyle = PageNumberStyle.RomanUpper;
section.PageSetup.PageSize = new SizeF(612, 792);
section.PageSetup.PageStartingNumber = 1;
section.PageSetup.VerticalAlignment = PageAlignment.Top;
//Add the page number field to even footer of the document
IWParagraph paragraph = section.HeadersFooters.EvenFooter.AddParagraph();
paragraph.AppendText("PageNumber_EvenPageFooter ");
paragraph.AppendField("Page", FieldType.FieldPage);
//Add the page number field to odd footer of the document
paragraph = section.HeadersFooters.OddFooter.AddParagraph();
paragraph.AppendText("PageNumber_OddPageFooter ");
paragraph.AppendField("Page", FieldType.FieldPage);
//Add the page number field to first footer of the document
paragraph = section.HeadersFooters.FirstPageFooter.AddParagraph();
//Add page number field to the document
paragraph.AppendText("PageNumber_FirstPageFooter ");
paragraph.AppendField("Page", FieldType.FieldPage);
//Add a paragraph to section
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");
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");
paragraph.AppendBreak(Syncfusion.DocIO.DLS.BreakType.PageBreak);
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");
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");
paragraph.AppendBreak(Syncfusion.DocIO.DLS.BreakType.PageBreak);
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");
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)
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
'Set page setup options
section.PageSetup.Orientation = PageOrientation.Landscape
section.PageSetup.Margins.All = 72
section.PageSetup.Borders.LineWidth = 2
section.PageSetup.DifferentFirstPage = True
section.PageSetup.DifferentOddAndEvenPages = True
section.PageSetup.FooterDistance = 42
section.PageSetup.HeaderDistance = 52
section.PageSetup.LineNumberingDistanceFromText = 10
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous
section.PageSetup.LineNumberingStartValue = 5
section.PageSetup.LineNumberingStep = 2
section.PageSetup.PageBorderOffsetFrom = PageBorderOffsetFrom.Text
section.PageSetup.PageBordersApplyType = PageBordersApplyType.AllPages
section.PageSetup.PageNumberStyle = PageNumberStyle.RomanUpper
section.PageSetup.PageSize = New SizeF(612, 792)
section.PageSetup.PageStartingNumber = 1
section.PageSetup.VerticalAlignment = PageAlignment.Top
'Add the page number field to even footer of the document
Dim paragraph As IWParagraph = section.HeadersFooters.EvenFooter.AddParagraph()
paragraph.AppendText("PageNumber_EvenPageFooter ")
paragraph.AppendField("Page", FieldType.FieldPage)
'Add the page number field to odd footer of the document
paragraph = section.HeadersFooters.OddFooter.AddParagraph()
paragraph.AppendText("PageNumber_OddPageFooter ")
paragraph.AppendField("Page", FieldType.FieldPage)
'Add the page number field to first footer of the document
paragraph = section.HeadersFooters.FirstPageFooter.AddParagraph()
'Add page number field to the document
paragraph.AppendText("PageNumber_FirstPageFooter ")
paragraph.AppendField("Page", FieldType.FieldPage)
'Add a paragraph to section
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")
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")
paragraph.AppendBreak(Syncfusion.DocIO.DLS.BreakType.PageBreak)
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")
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")
paragraph.AppendBreak(Syncfusion.DocIO.DLS.BreakType.PageBreak)
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")
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
Properties
Bidi
Gets or sets a value indication whether section contains right-to-left text. The default is false.
Declaration
public bool Bidi { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the section contains right-to-left text; otherwise, false |
Borders
Gets the page border. Read-only.
Declaration
public Borders Borders { get; }
Property Value
Type | Description |
---|---|
Borders | The Borders collection represents the left, right, top and bottom borders of the page |
ClientWidth
Gets width of client area. Read-only.
Declaration
public float ClientWidth { get; }
Property Value
Type | Description |
---|---|
System.Single | float value represents the text rendering area width. |
DefaultTabWidth
Gets or sets the length of the auto tab.
Declaration
public float DefaultTabWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The length of the auto tab. |
Remarks
"This property has been deprecated. Use the DefaultTabWidth property of WordDocument class to set default tab width for the document.
DifferentFirstPage
Gets or sets a value indicating whether a different header or footer is used on the first page. The default is false
Declaration
public bool DifferentFirstPage { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if a different header or footer is used on the first page; otherwise, false |
DifferentOddAndEvenPages
Gets or sets a value indicating whether a different header or footer is used on the odd and even pages. The default is false
Declaration
public bool DifferentOddAndEvenPages { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if a different header or footer is used on the odd and even pages; otherwise, false |
FirstPageTray
Gets or sets value for first paper source of the current section in paper settings
Declaration
public PrinterPaperTray FirstPageTray { get; set; }
Property Value
Type |
---|
PrinterPaperTray |
Examples
The following code example illustrates how to add a line number with start value for a section.
//Creates an instance of WordDocument.
WordDocument document = new WordDocument();
//Adds a new section into the Word document.
IWSection section= document.AddSection();
//Sets the PrinterPaperTray value for FirstPageTray in pagesetup options.
section.PageSetup.FirstPageTray = PrinterPaperTray.EnvelopeFeed;
//Adds a new simple paragraph into the section.
IWParagraph paragraph = section.AddParagraph();
//Adds new text to the paragraph.
paragraph.AppendText("Added paper source");
//Saves the resultant Word document.
document.Save("Sample.docx");
//Closes the document.
document.Close();
//Creates an instance of WordDocument.
Dim document As WordDocument = New WordDocument()
//Adds a new section into the Word document.
Dim section As IWSection = document.AddSection()
//Sets the PrinterPaperTray value for FirstPageTray in pagesetup options.
section.PageSetup.FirstPageTray = PrinterPaperTray.EnvelopeFeed
//Adds a new simple paragraph into the section.
Dim paragraph As IWParagraph = section.AddParagraph()
//Adds new text to the paragraph.
paragraph.AppendText("Added paper source")
//Saves the resultant Word document.
document.Save("Sample.docx")
//Closes the document.
document.Close()
FooterDistance
Gets or sets the distance (in points) between the footer and the bottom of the page.
Declaration
public float FooterDistance { get; set; }
Property Value
Type |
---|
System.Single |
HeaderDistance
Gets or sets the distance (in points) between the header and the top of the page.
Declaration
public float HeaderDistance { get; set; }
Property Value
Type |
---|
System.Single |
IsFrontPageBorder
Gets or sets a value indicating whether the current page border is the front page border. The default is true.
Declaration
public bool IsFrontPageBorder { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the current page border is front page; otherwise, false. |
LineNumberingDistanceFromText
Gets or sets the distance (in points) between the right edge of line numbers and the left edge of the document text.
Declaration
public float LineNumberingDistanceFromText { get; set; }
Property Value
Type |
---|
System.Single |
Examples
The following code example illustrates how to add a line number and its distance from margins of the document for a section.
//Open existing Word document.
WordDocument document = new WordDocument("Sample.docx");
//Iterate each section
foreach (WSection section in document.Sections)
{
//Set the line numbering mode for the particular section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous;
//Set the Distance value for the LineNumbering Mode.
section.PageSetup.LineNumberingDistanceFromText = 55.7f;
}
//Save the resultant Word document.
document.Save("Sample.docx");
//Close the document instance.
document.Close();
//Open existing Word document.
Dim document As New WordDocument("Sample.docx")
//Iterate each section
For Each section As WSection In document.Sections
//Set the line numbering mode for the particular section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous
//Set the Distance value for the LineNumbering Mode.
section.PageSetup.LineNumberingDistanceFromText = 55.7F
Next
//Save the resultant Word document.
document.Save("Sample.docx")
//Close the document instance.
document.Close()
LineNumberingMode
Gets or sets the way line numbering runs� that is, whether it starts over at the beginning of a new page or section or runs continuously.
Declaration
public LineNumberingMode LineNumberingMode { get; set; }
Property Value
Type |
---|
LineNumberingMode |
Examples
The following code example illustrates how to add a line number for a section.
//Open existing Word document.
WordDocument document = new WordDocument("Sample.docx");
//Iterate each section
foreach (WSection section in document.Sections)
{
//Set the Line numbering mode for the Particular Section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous;
}
//Save the resultant Word document.
document.Save("Sample.docx");
//Close the document instance.
document.Close();
//Open existing Word document.
Dim document As New WordDocument("Sample.docx")
//Iterate each section
For Each section As WSection In document.Sections
//Set the Line Numbering Mode for the Particular Section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous
Next
//Save the resultant Word document.
document.Save("Sample.docx")
//Close the document instance.
document.Close()
LineNumberingStartValue
Gets or sets the starting line number.
Declaration
public int LineNumberingStartValue { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code example illustrates how to add a line number with start value for a section.
//Open existing Word document.
WordDocument document = new WordDocument("Sample.docx");
//Iterate each section
foreach (WSection section in document.Sections)
{
//Set the line numbering mode for the Particular Section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous;
//Set the Starting value for the LineNumberingMode.
section.PageSetup.LineNumberingStartValue = 100;
}
//Save the resultant Word document.
document.Save("Sample.docx");
//Close the document instance.
document.Close();
//Open existing Word document.
Dim document As New WordDocument("Sample.docx")
//Iterate each section
For Each section As WSection In document.Sections
//Set the line numbering mode for the Particular Section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous
//Set the Starting Value for the LineNumbering Mode.
section.PageSetup.LineNumberingStartValue = 100
Next
//Save the resultant Word document.
document.Save("Sample.docx")
//Close the document instance.
document.Close()
LineNumberingStep
Gets or sets the numeric increment for line numbers. For example, if the CountBy property is set to 5, every fifth line will display the line number.
Declaration
public int LineNumberingStep { get; set; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code example illustrates how to add a line number with step value for a section.
//Open existing Word document.
WordDocument document = new WordDocument("Sample.docx");
//Iterate each section
foreach (WSection section in document.Sections)
{
//Set the line numbering mode for the Particular section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous;
//Set the Step value for the LineNumberingMode.
section.PageSetup.LineNumberingStep=2;
}
//Save the resultant Word document.
document.Save("Sample.docx");
//Close the document instance.
document.Close();
//Open existing Word document.
Dim document As New WordDocument("Sample.docx")
//Iterate each section
For Each section As WSection In document.Sections
//Set the line numbering mode for the Particular section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous
//Set the Step value for the LineNumberingMode.
section.PageSetup.LineNumberingStep = 2
Next
//Save the resultant Word document.
document.Save("Sample.docx")
//Close the document instance.
document.Close()
Margins
Gets or sets the distance (in points) between the all four edge of the page and the all four boundary of the body text.
Declaration
public MarginsF Margins { get; set; }
Property Value
Type |
---|
MarginsF |
Orientation
Gets or sets the orientation of the page.
Declaration
public PageOrientation Orientation { get; set; }
Property Value
Type |
---|
PageOrientation |
OtherPagesTray
Gets or sets value for other paper source of the current section in paper settings
Declaration
public PrinterPaperTray OtherPagesTray { get; set; }
Property Value
Type |
---|
PrinterPaperTray |
Examples
The following code example illustrates how to add a line number with start value for a section.
//Creates an instance of WordDocument.
WordDocument document = new WordDocument();
//Adds a new section into the Word document.
IWSection section= document.AddSection();
//Sets the PrinterPaperTray value for OtherPagesTray in pagesetup options.
section.PageSetup.OtherPagesTray = PrinterPaperTray.MiddleBin;
//Adds a new simple paragraph into the section.
IWParagraph paragraph = section.AddParagraph();
//Adds new text to the paragraph.
paragraph.AppendText("Added paper source");
//Saves the resultant Word document.
document.Save("Sample.docx");
//Closes the document.
document.Close();
//Creates an instance of WordDocument.
Dim document As WordDocument = New WordDocument()
//Adds a new section into the Word document.
Dim section As IWSection = document.AddSection()
//Sets the PrinterPaperTray value for OtherPagesTray in pagesetup options.
section.PageSetup.OtherPagesTray = PrinterPaperTray.MiddleBin
//Adds a new simple paragraph into the section.
Dim paragraph As IWParagraph = section.AddParagraph()
//Adds new text to the paragraph.
paragraph.AppendText("Added paper source")
//Saves the resultant Word document.
document.Save("Sample.docx")
//Closes the document.
document.Close()
PageBorderOffsetFrom
Gets or sets the position of page border.
Declaration
public PageBorderOffsetFrom PageBorderOffsetFrom { get; set; }
Property Value
Type |
---|
PageBorderOffsetFrom |
PageBordersApplyType
Gets or sets the value that determine on which pages border is applied.
Declaration
public PageBordersApplyType PageBordersApplyType { get; set; }
Property Value
Type |
---|
PageBordersApplyType |
PageNumbers
Gets the page number setup. Read-only.
Declaration
public PageNumbers PageNumbers { get; }
Property Value
Type |
---|
PageNumbers |
See Also
PageNumberStyle
Gets or sets the page number style.
Declaration
public PageNumberStyle PageNumberStyle { get; set; }
Property Value
Type |
---|
PageNumberStyle |
PageSize
Gets or sets page size in points.
Declaration
public SizeF PageSize { get; set; }
Property Value
Type |
---|
System.Drawing.SizeF |
PageStartingNumber
Gets or sets the starting page number.
Declaration
public int PageStartingNumber { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The page starting number. |
RestartPageNumbering
Gets or sets a value indicating whether to restart page numbering.
Declaration
public bool RestartPageNumbering { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if restart page numbering; otherwise, false. |
VerticalAlignment
Gets sets the vertical alignment of text on each page in a document or section.
Declaration
public PageAlignment VerticalAlignment { get; set; }
Property Value
Type |
---|
PageAlignment |
Methods
EnsureComposites()
Ensures the composites.
Declaration
protected override void EnsureComposites()
Overrides
GetDefComposite(Int32)
Get the DefValues for the key.
Declaration
protected override FormatBase GetDefComposite(int key)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | key |
Returns
Type |
---|
FormatBase |
Overrides
GetDefValue(Int32)
Returns the default values.
Declaration
protected override object GetDefValue(int key)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | key | The integer that specifies the key. |
Returns
Type | Description |
---|---|
System.Object | An object that specifies the default value. |
Overrides
InitXDLSHolder()
Registers child objects in XDSL holder.
Declaration
protected override void InitXDLSHolder()
Overrides
InsertPageNumbers(Boolean, PageNumberAlignment)
Inserts the page numbers.
Declaration
public void InsertPageNumbers(bool topOfPage, PageNumberAlignment horizontalAlignment)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | topOfPage | True to insert the page number at the top of the page; False to insert the page number at the bottom of the page. |
PageNumberAlignment | horizontalAlignment | The horizontal alignment of the page number. |
Examples
The following code example demonstrates how to insert page number.
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();
section.PageSetup.PageStartingNumber = 1;
section.PageSetup.RestartPageNumbering = true;
section.PageSetup.PageNumberStyle = PageNumberStyle.Arabic;
section.PageSetup.InsertPageNumbers(false, PageNumberAlignment.Center);
//Add the paragraph
IWParagraph 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()
section.PageSetup.PageStartingNumber = 1
section.PageSetup.RestartPageNumbering = True
section.PageSetup.PageNumberStyle = PageNumberStyle.Arabic
section.PageSetup.InsertPageNumbers(False, PageNumberAlignment.Center)
'Add the paragraph
Dim paragraph As IWParagraph = 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
ReadXmlAttributes(IXDLSAttributeReader)
Reads object data from xml attributes.
Declaration
protected override void ReadXmlAttributes(IXDLSAttributeReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeReader | reader | The IXDLSAttributeReader object. |
Overrides
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string that represents the current object. |
WriteXmlAttributes(IXDLSAttributeWriter)
Writes object data as xml attributes.
Declaration
protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeWriter | writer | The IXDLSAttributeWriter object. |