可以将水印添加到 Word 文档中,以告知其他人文档的所有权或状态。有时,您可能希望删除 Word 文档中的现有水印。本文将演示如何使用Spire.Doc for .NET从 C# 和 中的 Word 文档中删除水印。
Spire.Doc 最新下载(qun:767755948)/product/3368/download
为 .NET 安装 Spire.Doc
首先,您需要添加 Spire.Doc for .NET 包中包含的 DLL 文件作为 .NET 项目中的引用。DLL 文件可以从此链接下载或通过NuGet安装。
PM> Install-Package Spire.Doc
从 C# 和 中的 Word 文档中删除文本或图像水印
您可以通过将Document.Watermark属性设置为 null来删除 Word 文档的水印。
以下步骤向您展示如何从 Word 文档中删除水印:
初始化Document类的一个实例。使用Document.LoadFromFile()方法加载 Word 文档。通过将Document.Watermark属性设置为 null从文档中删除水印。使用Document.SaveToFile()方法保存结果文档。
【C#】
using Spire.Doc;namespace RemoveWatermark{class Program{static void Main(string[] args){//Create a Document instanceDocument doc = new Document();//Load a Word documentdoc.LoadFromFile("Sample.docx");//Remove the watermark from the documentdoc.Watermark = null;//Save the result documentdoc.SaveToFile("RemoveWatermark.docx", FileFormat.Docx);}}}
【】
using Spire.Doc;namespace RemoveWatermark{class Program{static void Main(string[] args){//Create a Document instanceDocument doc = new Document();//Load a Word documentdoc.LoadFromFile("Sample.docx");//Remove the watermark from the documentdoc.Watermark = null;//Save the result documentdoc.SaveToFile("RemoveWatermark.docx", FileFormat.Docx);}}}