How to add page border in microsoft word in programmatically in c#
Thank you.
plz provide the solution........
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Alex SmithRank #4,089 · 366 reputationPosted Sep 29, 2014, 6:59 PM EDT
using Spire.Doc;
using Spire.Doc.Documents;
namespace WordBorder
{
class PageBorders
{
static void Main(string[] args)
{
//Load Document
Document document = new Document();
document.LoadFromFile(@"E:\Work\Documents\Microsoft Word 2013 Preview.docx");
Section section = document.Sections[0];
//Add Page Borders with Special Style and Color
section.PageSetup.Borders.BorderType = BorderStyle.DoubleWave;
section.PageSetup.Borders.Color = Color.LightSeaGreen;
//Space between Border and Text
section.PageSetup.Borders.Left.Space = 50;
section.PageSetup.Borders.Right.Space = 50;
//Save and Launch
document.SaveToFile("PageBorders.docx", FileFormat.Docx);
System.Diagnostics.Process.Start("PageBorders.docx");
}
}
}
Note: This method is based on a C# Word component, you need to add its dll before running this sample code.Good luck.