Remove License Evaluation Watermarks & Text Messages Injected by Aspose.Words C# .NET

We’ve implemented document manipulation within our app and have a licensed version of Aspose. However, in one area of the application we overlooked the setting of the license. This has been released to customers and we now have a number of documents which have had the Aspose licence warnings and Header/Footer watermark images inserted.

To avoid the need to recreate the customer documents we are looking for a way where we might automate the removal of the warnings and watermark images with are licensed version. Whilst we could write something to search/remove instances of the warning text it would appear doing something similar for the watermark images is a little trickier, especially if the original document had its own watermark.

Could you advise whether there is a preferred method of achieving this please?

@Tim.Campbell,

When running in evaluation mode (without applying license), Aspose.Words currently injects following content in output document:

  1. Evaluation Only. Created with Aspose.Words. Copyright 2003-2021 Aspose Pty Ltd.
  2. This document was truncated here because it was created in the Evaluation Mode.
  3. Created with an evaluation copy of Aspose.Words. To discover the full versions of our APIs please visit: Professional On-Premise and Cloud-based solutions for working with Word document formats
  4. Watermark (Logo image of Aspose) at the center of all Pages
  5. It also limits the maximum document size to a few hundred paragraphs and truncates the remaining content

In addition to safely removing above content, the routine should be able to revert back all changes made by the evaluation version of Aspose.Words; for example, it adds headers/footers in output document even if the source document does not have any. We have logged your requirement in our issue tracking system. Your ticket number is WORDSNET-22197. We will further look into the details of this requirement and will keep you updated on the status of the linked ticket.

Hi Awais,
Working with Tim on this. Thanks for the info, could you please advise whether the name property of the shape objects is a static value for the watermark image? i.e. Picture 1026 & Picture 1027?

@ABew,

We have logged your question/query in our issue tracking system and will keep you posted here on further updates.

@ABew,

It is not a static value.

Unfortunately, there is no way to revert changes made by evaluation mechanism. The document will be truncated and cannot be restored to the original state. To avoid such kind of problems in future you have to add some mechanism to make sure the license was applied correctly.

Our License class raises InvalidOperationException exception if a user tries to set a wrong or expired license.

So, the following code can be used to check a license:

var license = new Aspose.Words.License();
var isWrongLicense = false;
try
{
   license.SetLicense("license.lic");
}
catch (InvalidOperationException)
{
   isWrongLicense = true;
}

Or one more way in case the license even was not set:

private static bool IsLicensed()
{
    const string testString = "test";
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
    builder.Write(testString);

    using (MemoryStream ms = new MemoryStream())
    {
        doc.Save(ms, SaveFormat.Docx);
        ms.Position = 0;
        doc = new Document(ms);
    }

    string test = doc.ToString(SaveFormat.Text).Trim();

    return doc.ToString(SaveFormat.Text).Trim() == testString;
}