Page border is just like our photo frame if we compare the word document to a photo. A lovely photo frame can beautify the outward appearance of a photo. By the same token, attractive page border can embellish the word document in a different way. Do you still remember your diploma in university? The border of your degree certificate looks dignified and distinctive. Different page border can be used in different cases. That is the effect of page border. Now let us look at how to insert page border in Word document with C#, VB.NET.
How to add page border in word document with C#, VB.NET
When I operate my word document, Spire.Doc always gives me best help to finish the task in minutes. It is an MS Word component, which supports C#, VB.NET, ASP.NET, ASP.NET MVC and Silverlight. Why not give it a try to Freely Install Spire.Doc on system?
Step1. Create a new project.
1. Create a new project in Visual Studio.
2. Set the Target Framework to be .NET Framework 4 in Properties.
3. Add Spire.Doc DLL as reference in Project.
Step2. Insert page border in word document.
1. Create a word document and add section in it.
C# Code:
//create a new document
Document doc = new Document();
Section section = doc.AddSection();
VB.NET Code:
'create a new document
Dim doc As New Document()
Dim section As Section = doc.AddSection()
2. Add text in Word document
C# Code:
// add text
section.AddParagraph().AppendText("This is a simple test by E-iceblue Co.,Ltd");
section.AddParagraph().AppendText("E-iceblue Co., Ltd. provides professional .NET components for .NET applications and Microsoft Visual Studio. \n");
section.AddParagraph().AppendText("The goal of e-iceblue is always to offer high-quality components for reading and writing office file formats. E-iceblue components have been widely-used by most of the Fortune 500 corporations\n");
section.AddParagraph().AppendText("The key developers of e-iceblue have over 10 years of combined experience developing high-performance, high-quality .net component technology\n");
VB.NET Code:
' add text
section.AddParagraph().AppendText("This is a simple test by E-iceblue Co.,Ltd")
section.AddParagraph().AppendText("E-iceblue Co., Ltd. provides professional .NET components for .NET applications and Microsoft Visual Studio. " & vbLf)
section.AddParagraph().AppendText("The goal of e-iceblue is always to offer high-quality components for reading and writing office file formats. E-iceblue components have been widely-used by most of the Fortune 500 corporations" & vbLf)
section.AddParagraph().AppendText("The key developers of e-iceblue have over 10 years of combined experience developing high-performance, high-quality .net component technology" & vbLf)
// add text
section.AddParagraph().AppendText("This is a simple test by E-iceblue Co.,Ltd");
section.AddParagraph().AppendText("E-iceblue Co., Ltd. provides professional .NET components for .NET applications and Microsoft Visual Studio. \n");
section.AddParagraph().AppendText("The goal of e-iceblue is always to offer high-quality components for reading and writing office file formats. E-iceblue components have been widely-used by most of the Fortune 500 corporations\n");
section.AddParagraph().AppendText("The key developers of e-iceblue have over 10 years of combined experience developing high-performance, high-quality .net component technology\n");
VB.NET Code:
' add text
section.AddParagraph().AppendText("This is a simple test by E-iceblue Co.,Ltd")
section.AddParagraph().AppendText("E-iceblue Co., Ltd. provides professional .NET components for .NET applications and Microsoft Visual Studio. " & vbLf)
section.AddParagraph().AppendText("The goal of e-iceblue is always to offer high-quality components for reading and writing office file formats. E-iceblue components have been widely-used by most of the Fortune 500 corporations" & vbLf)
section.AddParagraph().AppendText("The key developers of e-iceblue have over 10 years of combined experience developing high-performance, high-quality .net component technology" & vbLf)
3. Add page border in word
C# Code:
//insert page border
section.PageSetup.Borders.BorderType = Spire.Doc.Documents.BorderStyle.DoubleWave;
VB.NET Code: 'insert page border
section.PageSetup.Borders.BorderType = Spire.Doc.Documents.BorderStyle.DoubleWave
Step3. Save and launch the file.
C# Code:
//save and luanch
doc.SaveToFile("test.docx", FileFormat.Docx);
System.Diagnostics.Process.Start("test.docx");
VB.NET Code:
'save and luanch
doc.SaveToFile("test.docx", FileFormat.Docx)
System.Diagnostics.Process.Start("test.docx")
Preview
The page border can be changed according to your own need, the page border in above picture is only one. So why not try?
More Word Functions