News Category

Spire.Doc for .NET

Watermarks can be added to Word documents to inform other people about the documents' ownership or status. Sometimes, you may want to get rid of an existing watermark in a Word document. This article will demonstrate how to remove watermarks from Word documents in C# and VB.NET using Spire.Doc for .NET.

Install Spire.Doc for .NET

To begin with, you need to add the DLL files included in the Spire.Doc for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.Doc

Remove Text or Image Watermarks from Word Documents in C# and VB.NET

You can remove the watermark of a Word document by setting the Document.Watermark property as null.

The following steps show you how to remove the watermark from a Word document:

  • Initialize an instance of Document class.
  • Load a Word document using Document.LoadFromFile() method.
  • Remove the watermark from the document by setting the Document.Watermark property as null.
  • Save the result document using Document.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Doc;

namespace RemoveWatermark
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Document instance
            Document doc = new Document();
            //Load a Word document
            doc.LoadFromFile("Sample.docx");

            //Remove the watermark from the document
            doc.Watermark = null;

            //Save the result document
            doc.SaveToFile("RemoveWatermark.docx", FileFormat.Docx2013);
        }
    }
}

C#/VB.NET: Remove Text or Image Watermarks from Word Documents

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

We already have the documentation introducing how to convert Word to EPUB. However, you may want to add a cover image to EPUB when creating an EPUB book from a Word document. The following code snippets will demonstrate the same.

Step 1: Create a Document instance and load a sample Word file.

Document doc = new Document();
doc.LoadFromFile("SampleWordFile.docx");

Step 2: Load a picture to DocPicture object.

DocPicture picture = new DocPicture(doc);
picture.LoadImage(Image.FromFile("CoverImage.jpg"));

Step 3: Add the picture to EPUB as cover image when creating EPUB from the Word document.

doc.SaveToEpub("output.epub", picture);

Output:

Add a Cover Image when Converting Word to EPUB in C#, VB.NET

Full Code:

[C#]
using Spire.Doc;
using Spire.Doc.Fields;
using System.Drawing;
namespace DOCTOEPUB
{
    class Program
    {
        static void Main(string[] args)
        {
            Document doc = new Document();
            doc.LoadFromFile("SampleWordFile.docx");

            DocPicture picture = new DocPicture(doc);
            picture.LoadImage(Image.FromFile("CoverImage.jpg"));
            doc.SaveToEpub("output.epub", picture);  
        } 
     }
}
[VB.NET]
Imports Spire.Doc
Imports Spire.Doc.Fields
Imports System.Drawing
Namespace DOCTOEPUB
	Class Program
		Private Shared Sub Main(args As String())
			Dim doc As New Document()
			doc.LoadFromFile("SampleWordFile.docx")

			Dim picture As New DocPicture(doc)
			picture.LoadImage(Image.FromFile("CoverImage.jpg"))
			doc.SaveToEpub("output.epub", picture)
		End Sub
	End Class
End Namespace

With Spire.Doc, we can copy the content from one word document to another word document in C#. When we need to generate a large amount of documents from a single document, clone the document will be much easier. The clone method speeds up the generation of the word documents and developers only need one single line of code to get the copy of the word document.

Now we will show the code snippet of how to clone a word document in C#.

Step 1: Create a new instance of Document and load the document from file.

Document doc = new Document();
doc.LoadFromFile("Sample.docx",FileFormat.Docx2010);

Step 2: Clone the word document.

doc.Clone();

Step 3: Save the document to file.

doc.SaveToFile("Cloneword.docx", FileFormat.Docx2010);

Effective screenshot of clone the word document:

How to clone a word document in C#

Full codes of clone a word document:

using Spire.Doc;
namespace CloneWord
{
    class Program
    {
        static void Main(string[] args)
        {
            Document doc = new Document();
            doc.LoadFromFile("Sample.docx", FileFormat.Docx2010);
            doc.Clone();
            doc.SaveToFile("Cloneword.docx", FileFormat.Docx2010);
        }
    }
}
Page 8 of 56