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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Alex SmithPosted Sep 29, 2014, 10:59 PM
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.