How to Add Watermark in PDF Document with C#/VB.NET
Step 1 Load Document
PdfDocument document = new PdfDocument();
document.LoadFromFile(@"E:\work\A Thousand Suns.pdf");
PdfPageBase page = document.Pages[0];
Dim document As New PdfDocument()
document.LoadFromFile("E:\work\A Thousand Suns.pdf")
Dim page As PdfPageBase = document.Pages(0)
Step 2 Add Background Image
Image img = Image.FromFile(@"E:\work\Documents\heaven&hell.jpg");
page.BackgroundImage = img;
Dim img As Image = Image.FromFile("E:\work\Documents\heaven&hell.jpg")
page.BackgroundImage = img
Step 3 Add Text Watermark
PdfTilingBrush brush
= new PdfTilingBrush(new SizeF(page.Canvas.ClientSize.Width / 2, page.Canvas.ClientSize.Height / 2));
brush.Graphics.SetTransparency(0.5f);
brush.Graphics.TranslateTransform(brush.Size.Width / 2, brush.Size.Height / 2);
brush.Graphics.RotateTransform(-45);
Dim brush As New PdfTilingBrush(New SizeF(page.Canvas.ClientSize.Width \ 2, page.Canvas.ClientSize.Height \ 2))
brush.Graphics.SetTransparency(0.5F)
brush.Graphics.TranslateTransform(brush.Size.Width \ 2, brush.Size.Height \ 2)
brush.Graphics.RotateTransform(-45)
PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("Calibri", 24f,FontStyle.Bold));
brush.Graphics.DrawString("A Thousand Suns",
font1, PdfBrushes.DarkOrange, 0, 0,
new PdfStringFormat(PdfTextAlignment.Center));
page.Canvas.DrawRectangle(brush, new RectangleF(new PointF(0, 0), page.Canvas.ClientSize));
Dim font1 As New PdfTrueTypeFont(New Font("Calibri", 24.0F, FontStyle.Bold))
brush.Graphics.DrawString("A Thousand Suns", font1, PdfBrushes.DarkOrange, 0, 0, New PdfStringFormat(PdfTextAlignment.Center))
page.Canvas.DrawRectangle(brush, New RectangleF(New PointF(0, 0), page.Canvas.ClientSize))
Step 4 Save and Launch
document.SaveToFile("Watermark.pdf");
document.Close();
System.Diagnostics.Process.Start("Watermark.pdf");
document.SaveToFile("Watermark.pdf")
document.Close()
System.Diagnostics.Process.Start("Watermark.pdf")

How to Create Pivot Table in Excel with C#/VB.NET
Step 1 Load Excel File
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"E:\work\Documents\PartSalesInfo.xlsx");
Worksheet sheet = workbook.Worksheets[0];
sheet.Name = "Data Source";
Worksheet sheet2 = workbook.CreateEmptySheet();
sheet2.Name = "Pivot Table";
Dim workbook As New Workbook()
workbook.LoadFromFile("E:\work\Documents\PartSalesInfo.xlsx")
Dim sheet As Worksheet = workbook.Worksheets(0)
sheet.Name = "Data Source"
Dim sheet2 As Worksheet = workbook.CreateEmptySheet()
sheet2.Name = "Pivot Table"
Step 2 Create Pivot Table
CellRange dataRange = sheet.Range["A1:G17"];
PivotCache cache = workbook.PivotCaches.Add(dataRange);
PivotTable pt = sheet2.PivotTables.Add("Pivot Table", sheet.Range["A1"], cache);
Dim dataRange As CellRange = sheet.Range("A1:G17")
Dim cache As PivotCache = workbook.PivotCaches.Add(dataRange)
Dim pt As PivotTable = sheet2.PivotTables.Add("Pivot Table", sheet.Range("A1"), cache)
var r1 = pt.PivotFields["Vendor No"];
r1.Axis = AxisTypes.Row;
pt.Options.RowHeaderCaption = "Vendor No";
var r2 = pt.PivotFields["Description"];
r2.Axis = AxisTypes.Row;
Dim r1 = pt.PivotFields("Vendor No")
r1.Axis = AxisTypes.Row
pt.Options.RowHeaderCaption = "Vendor No"
Dim r2 = pt.PivotFields("Description")
r2.Axis = AxisTypes.Row
pt.DataFields.Add(pt.PivotFields["OnHand"], "SUM of OnHand", SubtotalTypes.Sum);
pt.DataFields.Add(pt.PivotFields["OnOrder"], "SUM of OnOrder", SubtotalTypes.Sum);
pt.DataFields.Add(pt.PivotFields["ListPrice"], "Average of ListPrice", SubtotalTypes.Average);
pt.BuiltInStyle = PivotBuiltInStyles.PivotStyleMedium12;
pt.DataFields.Add(pt.PivotFields("OnHand"), "SUM of OnHand", SubtotalTypes.Sum)
pt.DataFields.Add(pt.PivotFields("OnOrder"), "SUM of OnOrder", SubtotalTypes.Sum)
pt.DataFields.Add(pt.PivotFields("ListPrice"), "Average of ListPrice", SubtotalTypes.Average)
pt.BuiltInStyle = PivotBuiltInStyles.PivotStyleMedium12
Step 3 Save and Launch
workbook.SaveToFile("PivotTable.xlsx", ExcelVersion.Version2010);
System.Diagnostics.Process.Start("PivotTable.xlsx");
workbook.SaveToFile("PivotTable.xlsx", ExcelVersion.Version2010)
System.Diagnostics.Process.Start("PivotTable.xlsx")


Privacy Policy
This web site is maintained by E-iceblue Ltd. By accessing or using www.e-iceblue.com, you need to agree to terms of E-iceblue Online Privacy Policy, as outlined below. If you do not agree to these terms, please do not access or use this site.
Overview
E-iceblue has established this Onine Privacy Policy to help you understand how we intend to treat your Personal Information.
E-iceblue is committed to protecting your privacy. For accessing service from E-iceblue, we may ask for personal identification information (“Personal Information”), including your name (first and last), your e-mail address or some other contact information. The personal information can be provided by yourself or any other party. In general, you may visit our website without disclosing to us who you are and without revealing any Personal Information about yourself.
Also, you should be aware though, that if you choose to provide us with Personal Information, we may transfer such information, within E-iceblue or E-iceblue’s third party service providers, across borders and from your country or jurisdiction to other countries or jurisdictions around the world, subject to the limitations of this Privacy Policy.
E-iceblue Strives to comply with all applicable laws around the globe that are designed to protect your privacy. Although legal requirements may vary from country to country, E-iceblue intends to adhere to the principles set forth in this Online Privacy Policy.
Cookies and Other Tracking Technologies
When you visit www.e-iceblue.com, you may surf the site anonymously and access important information without revealing your identity. In order to analyze and improve our site, we use “cookies” to track your visit. A cookie is small amount of data that is transferred to your browser by a Web server and can only be read by the server that give it to you. “Cookies” cannot be executed as code or deliver viruses.
Most browsers are initially set to accept cookies. You can set your browser to notify you when you receive a cookie, therefore allowing you to decide whether or not to accept it. (For some Web pages that require an authorization, cookies are not optional. Users choosing not to accept cookies will not be able to access such pages.)
While E-iceblue uses cookies to track your visit to www.e-iceblue.com, and our Web servers automatically log the IP/Internet address of your computer. This information does not identify you personally and you remain anonymous unless you have otherwise provided e-iceblue with Personal Information.
Principles
The following principles we adopted to protect your privacy.
Choice
You may choose whether or not to provide Personal Information to E-iceblue. However, when you engage in certain activities on this site, such as ordering products, downloading software, or entering contests, E-iceblue may require that you provide certain information about yourself by filling out and submitting an online form. It is entirely optional for you to engage in these activities. If you elect to engage in these activities, E-iceblue may require that you provide certain personal information, such as your name, mailing address, e-mail address, and other personal identifying information.
Security
Wherever your Personal Information may be held by E-iceblue or a third party on E-iceblue’s behalf, reasonable and appropriate precautions, such as encryption, firewalls and like technologies, are and will be implemented to protect such Personal Information from loss, misuse or unauthorized access.
Access/Accuracy
To the extent that you do provide us with Personal Information, E-iceblue wishes to maintain it accurately and updated. Where we collect Personal Information from you, our goal is to provide a means of contacting E-iceblue should you need to access, update or correct that Information. If for any reason you desire to review such information, please contact us and we will make reasonable efforts to promptly provide you with such information. Further, if you notify us that such information is incorrect, or you wish to have such information removed, we will correct, amend, or delete your Personal Information as soon as practicable.
Third Party Services
In the interest of providing better service to its customers, E-iceblue is represented in the United States and in some foreign countries by authorized distributors and resellers who provide marketing, sales, and support services to E-iceblue customers. When you submit personal information to E-iceblue, you understand and agree that E-iceblue may allow E-iceblue’s authorized distributors and resellers access to your customer profile for the exclusive purpose of providing you with marketing, sales, and support services for E-iceblue products.
Your personal information will not be leased, sold, rented or otherwise made available to any other third party except to the extent necessary to comply with applicable laws, police investigations, or in legal proceedings where such information is relevant. Occasionally, E-iceblue allows access to database information to bonded mailing houses only for the purpose of allowing for the printing of mailing labels that are used for E-iceblue 's own direct mail and promotional purposes. In those instances, the third party is strictly bound by these terms.
Notwithstanding the foregoing, you hereby agree that E-iceblue may assign, sell, license, or otherwise transfer to a third party, your name, address, email address, member name and any other personal information in connection with an assignment, sale, joint venture, or other transfer or disposition of a material portion or essentially all of the assets or stock of E-iceblue or its affiliated entities.
Children's Privacy
www.e-iceblue.com is not designed nor structured to attract children. Accordingly, we do not intend to collect Personal Information from anyone we know to be under 13 years of age. If we are made aware that information is or has been submitted by or collected from a child under the age of thirteen, we will promptly delete this information.
Sensitive Information
We do not collect Sensitive Information such as medical, health, racial, ethnic, political, religious, philosophic, union membership or sexual orientation information. If we are made aware that we have received such information, we will promptly proceed to its deletion.
Notice
E-iceblue collects Personal Information on its Web site in order to record and support your participation in the activities you select. If you order a product, for example, the information is used to register your license and rights, if any, to ensure your eligibility to receive technical support, upgrade discounts, or other benefits that may be made available to registered users. If you enter a contest, information is collected to qualify the entry and contact you regarding the contest or prize awards. E-iceblue also uses information that you provide as part of our effort to keep you informed about the status of your subscription, product upgrades, special offers, and other E-iceblue products and services.
We will only collect Personal Information where it is relevant for the purposes for which we are collecting it. We will not process any Personal Information for any purposes that are incompatible with the purposes for which it has been collected or subsequently authorized by you.
Commitment
We, at E-iceblue, are committed to your right to privacy and we support current industry initiatives to preserve the integrity of individual privacy rights on the Internet. Protecting your privacy on-line is a rapidly evolving area, and E-iceblue's Web sites are continually evolving to meet these demands.
Your Consent
By using this Web site, you consent to the terms of our Online Privacy Policy and to E-iceblue's processing of Personal Information for the purposes outlined above. Should the Online Privacy Policy change, we will take reasonable steps to ensure that these changes are brought to your attention by posting all changes prominently on our Web site for a reasonable period of time.
Contact
If you have any comments or questions regarding our Online Privacy Policy, please contact us at comments@e-iceblue.com.
Renew Policy
Why Renew Subscription?
When you purchase a license from E-iceblue, you will get a full 1 year’s subscription software updates. We will send you an email to remind you if your subscription nears its subscription. However, without a subscription you can still use the product and get FREE support, but you are not allowed to get new features of hot fixes. If you have a problem that requires a hot fix but do not have a current subscription, you will have to renew before you can benefit from the fix.
When Should I Renew Subscription?
You can renew your subscription before its expiry date or after that. If your first time purchase is on September 12, the expiry date is on September 11 in the next year. We will send you an email to remind you around August 11.
What Does a Subscription Cost?
Renewing an existing subscription is cheaper than renewing an expired subscription. While your subscription is still running, adding a year to the subscription costs 80% of the current product price. To re-activate an expired subscription costs 70% of the current product price. Renewal adds twelve months to your subscription from the expiry date. However, if your expiry date is September 11, and you renew your license on October 10, then, the expiry data will be changed to October 9 in the next year.
How to Renew Subscription?
Log in to the purchase system with your account information. You can find the renewal discount coupon code in the purchase page. Use the coupon code to purchase the renewal. Leave a Note to offer us your registered license information including your email address, register name so that our technical support can send you renewal correctly.
If you bought the product from one of our resellers you can contact them when you need to renew your subscription. Our resellers can help you purchase a new subscription.
License Upgrade
If you purchased the license of Spire.Doc Developer Subscription and a few days later you found you need Spire.Doc Developer OEM Subscription, you can ask to Upgrade Your License.
When Can I Upgrade License?
After you purchase our product and receive license, you can only upgrade your license during the first 3 months. After 3 months, you need purchase what you want. However, you can get 10% OFF discount as a return customer.
How Much I Should Pay?
When you upgrade license, you just need pay the price difference. For example, if you purchased Spire.Doc Pro Edition Developer Subscription ($499) on May 1, 2012 and you want to upgrade to Spire.Office Developer Subscription ($999) on May 10, 2012, you just need pay $500. And the register data will be May 10, 2012.
Can I Upgrade My Spire.PDF to Spire.Doc?
No, you can’t. You can convert Spire.PDF to Spire.Office. Or you can convert Spire.PDF Developer Subscription to Spire.PDF OEM Subscription, Spire.PDF Site Enterprise or Spire.PDF Site OEM.
How to Upgrade?
When you found you need upgrade your license, please send email to sales@e-iceblue.com. You need offer us the old license information (Product Name, License Registered Name, Purchasing Date, Purchasing email address and what product license you want to upgrade to). Then, we will generate upgrade coupon code for you.
If you need more help, please contact our sales team.
How to Insert Page Border in Word with C#/VB.NET
Step 1 Create a Project
Step 2 Insert Page Border in Word Document
Document doc = new Document();
Section section = doc.AddSection();
// 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");
//insert page border
section.PageSetup.Borders.BorderType = Spire.Doc.Documents.BorderStyle.ThinThickLargeGap;
Dim doc As New Document()
Dim section As Section = doc.AddSection()
' 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)
Step 3 Save and Preview
doc.SaveToFile("test.docx", FileFormat.Docx);
System.Diagnostics.Process.Start("test.docx");
doc.SaveToFile("test.docx", FileFormat.Docx)
System.Diagnostics.Process.Start("test.docx")

How to Remove Word Sections with C#/VB.NET
Step 1 Create a Project
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Collections;
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports Spire.Doc.Collections
Step 2 Load Word Document
//load Word document
Document document = new Document();
document.LoadFromFile(@"D:\Sample.doc");
'load Word document
Dim document As New Document()
document.LoadFromFile("D:\Sample.doc")
Step 3 Remove Sections
//remove sections
document.Sections.RemoveAt(0);
'remove sections
document.Sections.RemoveAt(0)
Step 4 Save
//Save file
document.SaveToFile("sample.doc", FileFormat.Doc);
'Save file
document.SaveToFile("sample.doc", FileFormat.Doc)
How to Generate PDF Table in C#/VB.NET
Step 1 Create project and add reference
Step 2 Import namespace
using Spire.Pdf;
using Spire.Pdf.Graphics;
using Spire.Pdf.Tables;
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports Spire.Pdf.Tables
Step 3 Create PDF and make setting
//Create a pdf document.
PdfDocument doc = new PdfDocument();
//margin
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
PdfMargins margin = new PdfMargins();
margin.Top = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Bottom = margin.Top;
margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Right = margin.Left;
// Create new page
PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, margin);
float y = 10;
//title
PdfBrush brush1 = PdfBrushes.Black;
PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Bold));
PdfStringFormat format1 = new PdfStringFormat(PdfTextAlignment.Center);
page.Canvas.DrawString("Country List", font1, brush1, page.Canvas.ClientSize.Width / 2, y, format1);
y = y + font1.MeasureString("Country List", format1).Height;
y = y + 5;
'Create a pdf document.
Dim doc As New PdfDocument()
'margin
Dim unitCvtr As New PdfUnitConvertor()
Dim margin As New PdfMargins()
margin.Top = unitCvtr.ConvertUnits(2.54F, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point)
margin.Bottom = margin.Top
margin.Left = unitCvtr.ConvertUnits(3.17F, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point)
margin.Right = margin.Left
' Create new page
Dim page As PdfPageBase = doc.Pages.Add(PdfPageSize.A4, margin)
Dim y As Single = 10
'title
Dim brush1 As PdfBrush = PdfBrushes.Black
Dim font1 As New PdfTrueTypeFont(New Font("Arial", 16F, FontStyle.Bold))
Dim format1 As New PdfStringFormat(PdfTextAlignment.Center)
page.Canvas.DrawString("Country List", font1, brush1, page.Canvas.ClientSize.Width / 2, y, format1)
y = y + font1.MeasureString("Country List", format1).Height
y = y + 5
Step 4 Set PDF table’s data source
String[] data
= {
"Name;Capital;Continent;Area;Population",
"Argentina;Buenos Aires;South America;2777815;32300003",
"Bolivia;La Paz;South America;1098575;7300000",
"Brazil;Brasilia;South America;8511196;150400000",
"Canada;Ottawa;North America;9976147;26500000",
};
String[][] dataSource
= new String[data.Length][];
for (int i = 0; i < data.Length; i++)
{
dataSource[i] = data[i].Split(';');
}
Dim data As [String]() = {"Name;Capital;Continent;Area;Population", "Argentina;Buenos Aires;South America;2777815;32300003", "Bolivia;La Paz;South America;1098575;7300000", "Brazil;Brasilia;South America;8511196;150400000", "Canada;Ottawa;North America;9976147;26500000"}
Dim dataSource As [String]()() = New [String](data.Length - 1)() {}
For i As Integer = 0 To data.Length - 1
dataSource(i) = data(i).Split(";"C)
Next
Step 5 Create PDF table in C#/VB.NET and set its formats
PdfTable table = new PdfTable();
table.Style.CellPadding = 2;
table.Style.HeaderSource = PdfHeaderSource.Rows;
table.Style.HeaderRowCount = 1;
table.Style.ShowHeader = true;
table.DataSource = dataSource;
PdfLayoutResult result = table.Draw(page, new PointF(0, y));
y = y + result.Bounds.Height + 5;
PdfBrush brush2 = PdfBrushes.Gray;
PdfTrueTypeFont font2 = new PdfTrueTypeFont(new Font("Arial", 9f));
page.Canvas.DrawString(String.Format("* {0} countries in the list.", data.Length - 1), font2, brush2, 5, y);
Dim table As New PdfTable()
table.Style.CellPadding = 2
table.Style.HeaderSource = PdfHeaderSource.Rows
table.Style.HeaderRowCount = 1
table.Style.ShowHeader = True
table.DataSource = dataSource
Dim result As PdfLayoutResult = table.Draw(page, New PointF(0, y))
y = y + result.Bounds.Height + 5
Dim brush2 As PdfBrush = PdfBrushes.Gray
Dim font2 As New PdfTrueTypeFont(New Font("Arial", 9F))
page.Canvas.DrawString([String].Format("* {0} countries in the list.", data.Length - 1), font2, brush2, 5, y)
Step 6 Save and preview
//Save pdf file.
doc.SaveToFile("SimpleTable.pdf");
doc.Close();
System.Diagnostics.Process.Start("SimpleTable.pdf");
'Save pdf file.
doc.SaveToFile("SimpleTable.pdf")
doc.Close()
System.Diagnostics.Process.Start("SimpleTable.pdf")

How to Extract Text from Word Document
Step 1 Create a Project
using System;
using System.IO;
using System.Text;
using Spire.Doc;
using Spire.Doc.Documents;
namespace ExtractText
{
class Program
{
static void Main(string[] args)
{
}
}
}
Imports System.IO
Imports System.Text
Imports Spire.Doc
Imports Spire.Doc.Documents
Namespace ExtractText
Class Program
Private Shared Sub Main(args As String())
End Sub
End Class
End Namespace
Step 2 Load Word Document
Document doc = new Document();
doc.LoadFromFile(@"..\..\Test.doc",FileFormat.Doc);
Dim doc As New Document()
doc.LoadFromFile("..\..\Test.doc", FileFormat.Doc)
Step 3 Extract Text from Word Document
//new a stringBuilder to extract text from word document
StringBuilder sb = new StringBuilder();
//extract text from word document
foreach (Section section in doc.Sections)
{
foreach (Paragraph paragraph in section.Paragraphs)
{
sb.AppendLine(paragraph.Text);
}
}
'new a stringBuilder to extract text from word document
Dim sb As New StringBuilder()
'extract text from word document
For Each section As Section In doc.Sections
For Each paragraph As Paragraph In section.Paragraphs
sb.AppendLine(paragraph.Text)
Next
Next
Step 4 Save and Preview
//write the text of word document into a txt file
File.WriteAllText(@"..\..\result.txt", sb.ToString());
//launch the text file
System.Diagnostics.Process.Start(@"..\..\result.txt");
'write the text of word document into a txt file
File.WriteAllText("..\..\result.txt", sb.ToString())
'launch the text file
System.Diagnostics.Process.Start("..\..\result.txt")
How to Insert Page Break in Excel and Set View Mode as Page Break Preview
Step 1 Load Excel File
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"E:\work\Documents\PartSalesInfo.xlsx");
Worksheet sheet = workbook.Worksheets[0];
Dim workbook As New Workbook()
workbook.LoadFromFile("E:\work\Documents\PartSalesInfo.xlsx")
Dim sheet As Worksheet = workbook.Worksheets(0)
Step 2 Insert Page Break
workbook.Worksheets[0].HPageBreaks.Add(sheet.Range["A10"]);
workbook.Worksheets[0].VPageBreaks.Add(sheet.Range["G1"]);
workbook.Worksheets(0).HPageBreaks.Add(sheet.Range("A10"))
workbook.Worksheets(0).VPageBreaks.Add(sheet.Range("G1"))
Step 3 Set View Mode
workbook.Worksheets[0].ViewMode = ViewMode.Preview;
workbook.Worksheets(0).ViewMode = ViewMode.Preview
Step 4 Save and Launch
workbook.SaveToFile("ExcelPageBreak.xlsx", ExcelVersion.Version2010);
System.Diagnostics.Process.Start("ExcelPageBreak.xlsx");
workbook.SaveToFile("ExcelPageBreak.xlsx", ExcelVersion.Version2010)
System.Diagnostics.Process.Start("ExcelPageBreak.xlsx")


