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