Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Oct 16, 2018 9:25 pm

I cannot determine how to remove the watermark inside a MS Word 2013 document. the watermark is one of the default watermarks from the Design ribbon in Word. I saw an example of a simple C# program that simply uses doc.Watermark = null. I tried this, and the program causes the SaveToFile to blow up when I attempt to save the document that has the watermark removed.

Program Watermark:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Spire.Doc;
using Spire.License;

namespace Watermark
{
class Program
{
static void Main(string[] args)
{
if (args == null || args.Length == 0)
{
Console.WriteLine("No argument passed into program");
return;
}

Document doc = new Document();

doc.LoadFromFile(args[0]);

doc.Watermark = null;

doc.SaveToFile(@"bb.docx", FileFormat.Docx);

}
}
}

Stack trace:

G:\temp>Watermark.exe aa.docx

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at spr7068.7(ParagraphBase A_0)
at spr7068.8(ParagraphBase A_0)
at spr7068.0(ParagraphItemCollection A_0)
at spr7068.0(Paragraph A_0, Boolean A_1)
at spr7068.0(BodyRegion A_0, Boolean A_1)
at spr7068.0(BodyRegionCollection A_0, Boolean A_1)
at spr7068.7(Section A_0)
at spr7068.39()
at spr7068.49()
at spr7068.0(Document A_0)
at spr7068.0(Stream A_0, Document A_1)
at spr7068.0(String A_0, Document A_1)
at Spire.Doc.Document.9(String A_0)
at Spire.Doc.Document.SaveToFile(String fileName, FileFormat fileFormat)
at Watermark.Program.Main(String[] args) in C:\Users\s136319\documents\visual studio 2015\Projects\watermark\Watermark\Program.cs:line 28

Input:

aa.docx with one of the Word->Design->"Draft 1" watermark inserted in a blank page.

Any help for removing a watermark?
thaks

flingylingy
 
Posts: 1
Joined: Tue Oct 16, 2018 5:59 pm

Wed Oct 17, 2018 2:21 am

Hello,

Thanks for your inquiry.
I did notice the exception occurred with our free version. Sorry that we have no plan to maintain the free version at present. Please upgrade to our latest commercial version Spire.Doc Pack(hot fix) Version:6.10.2 to test, I have confirmed that the exception doesn't exist in this version. If there is any question, please provide your input word document to help us further investigate your issue. You could send it to us via email(support@e-iceblue.com).

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Mon Oct 22, 2018 7:44 am

Hello,

Greetings from E-iceblue.
Did our commercial version work for you? Thanks for your valuable feedback and time.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Doc