Skip to content

Instantly share code, notes, and snippets.

Add Text or Image Watermarks to Documents in C#

The below C# code example demonstrates how to convert a Word document to PDF and then add a text watermark to the converted PDF file in your C# .NET applications.

API to Use

View a list of all supported file formats https://docs.groupdocs.com/conversion/net/supported-document-formats/

Installation

Download GroupDocs.Conversion library from https://downloads.conholdate.com/total/net or install the whole package directly from Nuget https://www.nuget.org/packages/Conholdate.Total/ into your workplace.

// Supports converting documents and adding watermarks to 100+ file formats including Word, Excel, PowerPoint, Project, Images, Web, Email, Metafiles and Diagrams
// Supported file formats: https://docs.groupdocs.com/conversion/net/supported-document-formats/
using (Converter converter = new Converter("input.pptx"))
{
WatermarkOptions watermark = new WatermarkOptions
{
Text = "Sample watermark",
Color = Color.Red,
Width = 100,
Height = 100,
Background = true
};
PdfConvertOptions options = new PdfConvertOptions
{
Watermark = watermark
};
converter.Convert("output.pdf", options);
// Supports converting documents and adding watermarks to 100+ file formats including Word, Excel, PowerPoint, Project, Images, Web, Email, Metafiles and Diagrams
// Supported file formats: https://docs.groupdocs.com/conversion/net/supported-document-formats/
using (Converter converter = new Converter("input.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("output.pdf", options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment