How to remove watermark from PDF file using .NET

I am using a temp license.
Getting Below exception:
An unhandled exception of type ‘System.NullReferenceException’ occurred in Aspose.Pdf Additional information: Object reference not set to an instance of an object.

Error Line:
PossibleWatermarkCollection possibleWatermarks = doc.FindWatermarks();

Below is the full code used:
string FilePath= @“E:\Pdf\Confidential PDF 2 (Writer).pdf”;
// For complete examples and data files, please go to GitHub - groupdocs-watermark/GroupDocs.Watermark-for-.NET: GroupDocs.Watermark for .NET examples, plugins and showcase projects
using (PdfDocument doc = Document.Load(FilePath))
{
// Initialize search criteria
ImageSearchCriteria imageSearchCriteria = new ImageDctHashSearchCriteria(@“E:\ZonesCorp\Deployment\ZC\images\icons.png”);
TextSearchCriteria textSearchCriteria = new TextSearchCriteria(“CONFIDENTIAL”);

            //PossibleWatermarkCollection possibleWatermarks = doc.Pages[0].FindWatermarks(imageSearchCriteria.Or(textSearchCriteria));
            TextSearchCriteria searchCriteria = new TextSearchCriteria("CONFIDENTIAL", false);
            PossibleWatermarkCollection possibleWatermarks = doc.FindWatermarks();
            // Remove all found watermarks
            for (var i = possibleWatermarks.Count - 1; i >= 0; i--)
            {
                possibleWatermarks.RemoveAt(i);
            }

            doc.Save();

@ali.mds,

Please provide us the following details so that we can investigate the issue at our end.

  • Problematic PDF document
  • Version of GroupDocs.Watermark for .NET API

Hi Usman,
Confidential PDF 2 (Writer).pdf (113.3 KB)
The version of GroupDocs.Watermark is 19.5.1.0.

Thanks

@ali.mds,

We are able to reproduce your reported issue at our end. This issue has been logged into our Issue Tracking System as WATERMARKNET-1143 for further investigation. We shall notify you here as soon as we have any updates for you.

Hi Usman,
Thanks for your quick action.

Appreciate if issue could be resolve in this week as we are in mid of a POC.

Regards

@ali.mds,

We shall try our best to fix the issue as soon as possible, however, we can not guarantee any ETA at the moment. We appreciate your cooperation in this regard.

Hi Usman,
Any luck to for solution of issue.

Regards

@ali.mds,

I am afraid that, at the moment, the issue is still in progress and we hope to share some updates soon. We appreciate your patience.

The issue you have found earlier (filed as WATERMARKNET-1143) has been fixed in this update. This message was posted using Bugs notification tool by usman.aziz