Convert and add watermark to a document using C#
1 min readOct 3, 2019
You might be looking for an API that can convert a source document to PDF or any other supported file format and add a watermark on it simultaneously. Watermark could be of text or image type.
using(Converter converter = new Converter(“sample.docx”))
{
WatermarkOptions watermark = new WatermarkOptions
{
Text = “Sample watermark”,
Color = Color.Red,
Width = 100,
Height = 100,
Background = true
};
PdfConvertOptions options = new PdfConvertOptions
{
Watermark = watermark
};
converter.Convert(“converted.pdf”, options);
}
In above code snippet you can see that a Word file is being converted to PDF. Using WatermarkOptions class, watermark properties (e.g. text, color) could be defined.
All you have to do is to integrate GroupDocs.Conversion for .NET DLL in your project.