We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I set the document page margins?

Platform: WinForms |
Control: DocIO

Syncfusion Essential DocIO is a .NET Word library used to create, read, and edit Word documents programmatically without Microsoft Word or interop dependencies. Using this library, you can set page margins for Word document through MarginsF class. You can set the document page margin settings like margin’s left, right, top and bottom. Then its object is assigned to section.PageSetup.Margins API.

Set page margins for Word document programmatically in C#


// Setting document page margins.
MarginsF pagemargins = new MarginsF();
pagemargins.Bottom = 100;
pagemargins.Top = 100;
pagemargins.Left = 75;
pagemargins.Right = 75;
// Assigning document page margins to the current section.
section.PageSetup.Margins = pagemargins;


' Setting document page margins.
Dim pagemargins As MarginsF = New MarginsF()
pagemargins.Bottom = 100
pagemargins.Top = 100
pagemargins.Left = 75
pagemargins.Right = 75
' Assigning document page margins to the current section.
section.PageSetup.Margins = pagemargins

A complete working example of how to set page margins for Word document in C# can be downloaded from Page-Margins_In-Word.zip


Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile