Articles in this section
Category / Section

How do I set the document page margins in WinForms DocIO?

2 mins read

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#

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;

VB

' 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

Note:

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.

 

Conclusion

I hope you enjoyed learning about how do I set the document page margins in WinForms DocIO.

You can refer to our DocIo feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied