What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 61071 |  Welcome, Guest!   Register  Login
 Home > Blogs > C# > Add Page Border in Word Document with C#, VB.NET ...
Lacy

Add Page Border in Word Document with C#, VB.NET

 Blog author: Lacy | Posted on: 5/29/2012 | Category: C# Blogs | Views: 975 | Status: [Member] | Points: 75 | Alert Moderator   


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. 


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)

3.     Insert 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 launch 
            doc.SaveToFile("test.docx", FileFormat.Docx);
            System.Diagnostics.Process.Start("test.docx");

VB.NET Code:

           'save and launch 
            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? 



Found interesting? Add this to:


About Keating Arly

Experience:1 year(s)
Home page:http://www.e-iceblue.com
Member since:Tuesday, March 27, 2012
Level:Starter
Status: [Member]
Biography:
>> Write Response - Respond to this post and get points

More Blogs

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/22/2013 8:48:44 AM