// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
var inputFolder = SourceFolderPath;
var outputFolder = SourceFolderPath + "/output";
var logo = @"D:\logo.png";
var files = Directory.GetFiles(inputFolder);
ImageSearchCriteria imageSearchCriteria = new ImageDctHashSearchCriteria(logo);
var regex = new Regex(@"^Company\sName$", RegexOptions.IgnoreCase);
TextSearchCriteria textSearchCriteria = new TextSearchCriteria(regex);
foreach (var file in files)
{
try
{
using (var doc = Document.Load(file))
{
var watermarks = doc.FindWatermarks(textSearchCriteria.Or(imageSearchCriteria));
watermarks.Clear();
doc.Save(Path.Combine(outputFolder, Path.GetFileName(file)));
}
}
catch (UnsupportedFileTypeException)
{
Console.WriteLine("File format is not supported. File = {0}", Path.GetFileName(file));
}
}