How to: Configure the Page Layout Programmatically

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.

Document document = richEditControl1.Document;
document.Unit = DevExpress.Office.DocumentUnit.Inch;
document.Sections[0].Page.PaperKind = System.Drawing.Printing.PaperKind.A6;
document.Sections[0].Page.Landscape = true;
document.Sections[0].Margins.Left = 2.0f;