Reason To Add Watermark In Word And How (With Microsoft Word And C#)
Sign in

Reason to Add Watermark in Word and How (with Microsoft Word and C#)

Watermark is often used in Word document. It can be images or texts. Although watermark has nothing to do with contents, it doesn’t influence the value of documents.

Why do people want to add watermark? Watermark can confirm the creator of documents and the completeness of contents. Also, watermark can be recognized as a mark to protect document. Generally speaking, watermark cannot be edited. If the original contents are changed, watermark will be changed as well.

In order to make document be more appealed, people may use some beautiful pictures as watermark. Therefore, sometimes watermark likes background of one document.

In Microsoft Word, we can add watermark directly. Click Format menu and then select background. Choose watermark and a window pops up. There are three selections, no watermark, image watermark and text watermark. If choosing image watermark, we need to select an image from our computer and set the size. If choosing text watermark, we can write new words or use the default words. Also, we can set the words’ size, color and type.

Besides using Microsoft directly, programmers may use C# or other language to add watermark in Word.

Now, I introduce a method about how to add Word watermark with C#.

Note: Spire.Doc needs to be installed.

 

private void button1_Click(object sender, EventArgs e)

{

//Create word document

Document document = new Document();

InsertWatermark(document);

//Save doc file.

document.SaveToFile("Sample.doc",FileFormat.Doc);

WordDocViewer("Sample.doc");

//Launching the MS Word file.

private void InsertWatermark(Document document)

{

Paragraph paragraph = document.AddSection().AddParagraph();

paragraph.AppendText("The sample demonstrates how to insert a watermark into a document.");

paragraph.ApplyStyle(BuiltinStyle.Heading2);

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph.AppendText("Microsoft Word is a word processor designed by Microsoft. It was first released in 1983 under the name Multi-Tool Word for Xenix systems. Subsequent versions were later written for several other platforms including IBM PCs running DOS (1983), the Apple Macintosh (1984), the AT&T Unix PC (1985), Atari ST (1986), SCO UNIX, OS/2, and Microsoft Windows (1989).");

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph.AppendText("Spire.Doc can generate, modify, convert, render and print documents without utilizing Microsoft Word.");

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph.AppendText("The sample demonstrates how to insert a watermark into a document.");

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph.AppendText("Microsoft Word is a word processor designed by Microsoft. It was first released in 1983 under the name Multi-Tool Word for Xenix systems. Subsequent versions were later written for several other platforms including IBM PCs running DOS (1983), the Apple Macintosh (1984), the AT&T Unix PC (1985), Atari ST (1986), SCO UNIX, OS/2, and Microsoft Windows (1989).");

paragraph = document.Sections[0].AddParagraph();

paragraph = document.Sections[0].AddParagraph();

paragraph.AppendText("Spire.Doc can generate, modify, convert, render and print documents without utilizing Microsoft Word.");

TextWatermark txtWatermark = new TextWatermark();

txtWatermark.Text = "Watermark Demo";

txtWatermark.FontSize = 90;

txtWatermark.Layout = WatermarkLayout.Diagonal;

document.Watermark = txtWatermark;

}

private void WordDocViewer(string fileName)

{

try

{

System.Diagnostics.Process.Start(fileName);

}

catch { }

}

start_blog_img