Section Format in ASP.NET Core DOCX Editor

14 Aug 20261 minute to read

ASP.NET Core DOCX Editor (Document Editor) supports various section formatting such as page size, page margins, and more.

Page size

You can get or set the size of a section at the cursor position by using the following sample code.

documenteditor.selection.sectionFormat.pageWidth = 500;
documenteditor.selection.sectionFormat.pageHeight = 600;

You can change the orientation of the page by swapping the values of page width and height respectively.

Page margins

The left and right page margins define the gap between the document content and the left and right sides of the page. The top and bottom page margins define the gap between the document content and the header and footer of the page.

documenteditor.selection.sectionFormat.leftMargin = 10;
documenteditor.selection.sectionFormat.rightMargin = 10;
documenteditor.selection.sectionFormat.bottomMargin = 10;
documenteditor.selection.sectionFormat.topMargin = 10;

NOTE

The maximum value of Margin is 1584, as per the Microsoft Word application, and you can set any value less than or equal to 1584 to this property. If you set any value greater than 1584, then the Syncfusion Document Editor will automatically reset it to 1584.

Header distance

You can define the distance of header content from the top of the page by using the following sample code.

documenteditor.selection.sectionFormat.headerDistance = 72;

You can define the distance of footer content from the bottom of the page by using the following sample code.

documenteditor.selection.sectionFormat.footerDistance = 72;

Online demo

Explore how to apply section formatting in Word documents using the ASP.NET Core Document Editor in this live demo.

See also