Traditionally, watermark is formed when marking paper. It is not printed on the face of paper but in the middle. Therefore, it can present others from forging the paper which watermark has been added.

Gradually, watermark is applied for electronic documents. As is known, along with sharp development of internet, people often share useful material with Word or other documents online. However, some people may steal the documents. So, the original owners need to take measures to protect the documents. Watermark is one of the methods.

Besides protecting, watermark can show properties for one document. For example, if the document is an important or secret file, we can add "Important" or "Secret" in the document.

In this post, I take MS Word as example and introduce one method about how to add watermark withVB.Net. Generally speaking, there are two types of watermark, image or text. And I will add text watermark in my document.

Firstly, we should prepare an existed Word document or create a new one. Then add text in it.

In this method, I have used a component: Spire.Doc, which specializes in operating Word for Silverlight and .NET, including generating, reading, editing and realizing other functions in MS Word. So, add its DLL file as reference, and then use the following code.

Imports System.ComponentModel

Imports System.Text

Imports Spire.Doc

Imports Spire.Doc.Documents

Module Watermark

    Sub Main()

        'Create word document

        Dim document_Renamed As New Document()

        InsertWatermark(document_Renamed)

        'Save doc file.

        document_Renamed.SaveToFile("watermark.doc", FileFormat.Doc)

        'Launching the MS Word file.

        System.Diagnostics.Process.Start("watermark.doc")

    EndSub

    PrivateSub InsertWatermark(By Val document_Renamed As Document)

        Dim paragraph_Renamed As Paragraph= document_Renamed.AddSection().AddParagraph()

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

        paragraph_Renamed.ApplyStyle(BuiltinStyle.Heading2)

        Dim txtWatermark As New TextWatermark()

        txtWatermark.Text = "Sample Document"

        txtWatermark.FontSize = 90

        txtWatermark.Layout = WatermarkLayout.Diagonal

        document_Renamed.Watermark = txtWatermark

    EndSub

EndModule