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();