Word控件Spire.Doc 【页面背景】教程(8) ;在 C# 中将文本水印和图像水印添加到 Word 文档

本节将演示如何使用 Spire.Doc 在 C# 中为 Word 文档添加文本水印和图像水印。

文字水印和图片水印是Word文档中的两种水印。文本水印总是显示一些与单词上下文相关的附加信息。而图像水印用于使Word文档更具吸引力。本节将演示如何使用 Spire.Doc 在 C# 中为 Word 文档添加文本水印和图像水印。

在 C# 中添加图像水印:

using Spire.Doc;namespace SetImageWatermark{class Program{static void Main(string[] args){{//create a new instance of Document and load the document from file.Document doc = new Document();doc.LoadFromFile("Sample.docx", FileFormat.Docx2013);//create a new instance of the PictureWatermark and load the picture from file.PictureWatermark picture = new PictureWatermark();picture.Picture = System.Drawing.Image.FromFile("logo.png");//set the image watermark scaling and Washout propertypicture.Scaling = 20;picture.IsWashout = false;//add the picture watermarkdoc.Watermark = picture;//save the document to filedoc.SaveToFile("ImageWatermark.docx", FileFormat.Docx2013);}}}}

在 C# 中将文本水印和图像水印添加到 Word 文档
在 C# 中添加文本水印:

using Spire.Doc;using Spire.Doc.Documents;using System.Drawing;namespace SetTextWatermark{class Program{static void Main(string[] args){{//create a new instance of Document and load the document from file.Document doc = new Document();doc.LoadFromFile("Sample.docx", FileFormat.Docx2013);//create a new instance of the TextWatermarkTextWatermark txtWatermark = new TextWatermark();//set the text watermark with text string, font, color and layout.txtWatermark.Text = "Confidential";txtWatermark.FontSize = 45;txtWatermark.Color = Color.Green;txtWatermark.Layout = WatermarkLayout.Diagonal;//add the text watermarkdoc.Watermark = txtWatermark;//save the file.doc.SaveToFile("TextWatermark.docx", FileFormat.Docx2013);}}}}

在 C# 中将文本水印和图像水印添加到 Word 文档

欢迎下载|体验更多E-iceblue产品

获取更多信息请咨询在线客服  


标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年6月8日
下一篇 2022年6月8日

相关推荐

发表回复

登录后才能评论