How to add Word text and image watermark in C#

Adding watermarks to documents is an important way to achieve anti-counterfeiting of important documents and declare authority. The following article will introduce how to use Free Spire.Doc for .NET (Community Edition) to add Word watermarks, including text watermarks and image watermarks.

This article is reproduced from the blog: http://www.cnblogs.com/Yesi/p/5085903.html 

C#

using Spire.Doc;
using Spire.Doc.Documents;
 
namespace Add_Watermark_To_Word
{
    class Program
    {
        static void Main(string[] args)
        {
            Document doc = new Document();
            doc.LoadFromFile("XML file introduction.doc");
 
            //set image watermark
            /*PictureWatermark picture = new PictureWatermark();
            picture.Picture = System.Drawing.Image.FromFile("花朵_2.jpg");
            picture.Scaling = 80;
            doc.Watermark = picture;*/
 
            //set text watermark
            TextWatermark txtWatermark = new TextWatermark();
            txtWatermark.Text = "Microsoft";
            txtWatermark.FontSize = 90;
            txtWatermark.Layout = WatermarkLayout.Diagonal;
            doc.Watermark = txtWatermark;
 
            doc.SaveToFile("Watermark.doc");
            System.Diagnostics.Process.Start("水印.doc");
        }
    }
}

 

Text watermark effect

 

Picture watermark effect

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326148658&siteId=291194637