Back to Devexpress

How to: Configure the Page Layout Programmatically

wpf-10072-controls-and-libraries-rich-text-editor-examples-layout-how-to-configure-the-page-layout-programmatically.md

latest1.2 KB
Original Source

How to: Configure the Page Layout Programmatically

  • Jun 21, 2023

This example illustrates how to adjust page settings in code.

The page layout settings in the API pertain to the document’s section. Therefore, you need to change the SectionPage properties to adjust page settings.

The following code specifies the page layout settings for the first section of the document: the A6 paper in landscape orientation with the left margin set to two inches.

View Example

csharp
document.Unit = DevExpress.Office.DocumentUnit.Inch;
document.Sections[0].Page.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.A6;
document.Sections[0].Page.Landscape = true;
document.Sections[0].Margins.Left = 2.0f;
vb
document.Unit = DevExpress.Office.DocumentUnit.Inch
document.Sections(0).Page.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.A6
document.Sections(0).Page.Landscape = True
document.Sections(0).Margins.Left = 2.0F