Syncfusion.DocIO.Base
Members  Example 


Syncfusion.DocIO.DLS Namespace : WPageSetup Class

WPageSetup Class

Represents the page setup description.
Object Model
WPageSetup ClassBorders ClassWordDocument ClassMarginsF ClassPageNumbers Class
Syntax
Example

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
Inheritance Hierarchy

System.Object
   Syncfusion.DocIO.DLS.OwnerHolder
      Syncfusion.DocIO.DLS.XML.XDLSSerializableBase
         Syncfusion.DocIO.DLS.WPageSetup

AssemblyVersion

Syncfusion.DocIO.Base: 17.1460.0.38

See Also