// 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 files = Directory.GetFiles(inputFolder);
var font = new Font("Arial", 8, FontStyle.Bold);
var watermark = new TextWatermark("CONFIDENTIAL", font);
watermark.HorizontalAlignment = HorizontalAlignment.Center;
watermark.VerticalAlignment = VerticalAlignment.Center;
watermark.RotateAngle = -45;
watermark.SizingType = SizingType.ScaleToParentDimensions;
watermark.ScaleFactor = 0.8;
watermark.Opacity = 0.5;
watermark.ForegroundColor = Color.Red;
foreach (var file in files)
{
try
{
using (var doc = Document.Load(file))
{
doc.AddWatermark(watermark);
doc.Save(Path.Combine(outputFolder, Path.GetFileName(file)));
}
}
catch (UnsupportedFileTypeException)
{
Console.WriteLine("File format is not supported. File = {0}", Path.GetFileName(file));
}
}