Back to Devexpress

How to: Configure the Page Layout Programmatically

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

latest1.3 KB
Original Source

How to: Configure the Page Layout Programmatically

  • May 29, 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 document = richEditControl1.Document;
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
Dim document As Document = richEditControl1.Document
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