How to Use C# Insert Borders in Word Document
you will be introduced a solution to insert border in Word document by using C#.
Borders in Word document can be used to decorate Word document if we can set border style and color. Spire.Doc for .NET, as a professional .NET Word document, it can help us easily insert borders in Word document with styles and color designed.
Download Spire.Doc for .NET Here. Make sure Spire.Doc for .NET and Visual Studio are correctly installed on system. Follow the simple steps below to insert borders in Word document with C#.
Step 1 Create Project
Create a C# project in visual studio add Spire.Doc.dll as reference. The default setting of Spire.Doc.dll is placed under "C:\Program Files\e-iceblue\Spire.Doc\Bin”. Select assembly Spire.Doc.dll and click OK to add it to the project.
Step 2 Load Word Document
Load the word document which we need insert borders. Use the following code below to do the job:
Document document = new Document();
Section section = document.Sections;
Step 3 Insert Borders in Word Document
First, follow the code below to insert and set border style.
section.PageSetup.Borders.BorderType = BorderStyle.ThickThinLargeGap;
section.PageSetup.Borders.Color = Color.DeepSkyBlue;
Second, set alignment for the borders.
section.PageSetup.Borders.Left.Space = 100;
section.PageSetup.Borders.Right.Space = 100;
Step 4 Save and Preview
After setting styles, save the design by using the code below.
generate, read, write and modify Word document for .NET. It supports C#, VB.NET, ASP.NET, ASP.NET and MVC. Click to learn more...