Remove Watermark from Word in C#/VB.NET
In
Word, watermarks, such as text watermarks or image watermarks, can effectively
indicate ownership and usage standards. The purpose of this article is to
provide a method of how to delete watermarks from Word documents containing
watermark effects.Documents
with text watermarks or images watermarks can both be deleted. The following is
the detailed method and steps.
Programming
Environment
In this test, Free Spire.Doc
for .NET is introduced into the program. The Spire.Doc.dll file can be
referenced by:
Method 1:
Download Free
Spire.Doc for .NET locally, unzip it, and install it. After the
installation is complete, find Spire.Doc.dll in the BIN folder under the
installation path. Then open the "Solution Explorer" in Visual
Studio, right-click "References", "Add Reference", and add
a reference to the dll file in the BIN folder of the local path to the program.
Method 2:
Install via NuGet. It can
be installed by the following 2 methods:
(1) You can open the
"Solution Explorer" in Visual Studio, right-click
"References", "Manage NuGet Packages", then search for
"Free Spire.Doc", and click "Install". Wait for the program
installation to complete.
(2) Copy the following
content to the PM console installation.
Install-Package FreeSpire.Doc -Version 10.2.0
Specific
Steps:
l Create
a new word document object and load the word document that needs to remove the
watermark using Document.LoadFromFile() method.
l Remove
the watermark from the document by setting the Document.Watermark property as
null.
l Save the file using
Document.SaveToFile() method.
Full
Code:
【C#】
using System;
using System.Windows.Forms;
using Spire.Doc;
using Spire.Doc.Documents;
namespace RemoveWatermark
{
class Program
{
static void Main(string[] args)
{
//Create a new word document object and load the word
document that needs to remove the watermark
Document doc = new Document();
doc.LoadFromFile("Sample.docx", FileFormat.Docx2013);
// Remove the watermark from the document
doc.Watermark = null;
//Save the file
doc.SaveToFile("RemoveWatermark.docx", FileFormat.Docx2013);
}
}
}
【VB.NET】
Imports System
Imports System.Windows.Forms
Imports Spire.Doc
Imports Spire.Doc.Documents
Namespace RemoveWatermark
Class Program
Private Shared Sub Main(ByVal args() As String)
'Create a new word document object and load the word document that needs to remove the watermark
Dim doc As Document = New Document
doc.LoadFromFile("Sample.docx", FileFormat.Docx2013)
' Remove the watermark from the document
doc.Watermark = Nothing
'Save the file
doc.SaveToFile("RemoveWatermark.docx", FileFormat.Docx2013)
End Sub
End Class
End Namespace
Effective Shot:
Comments
Post a Comment