Examples

Watermark PDF

Add watermarks as text, an image, or any other page element to a PDF document using DynamicPDF Core Suite.

How to Add Image Watermark to PDF in C#

The ImageWatermark class adds an Image Watermark to a PDF. The following steps and sample code illustrate adding an image watermark to a PDF document using DynamicPDF Core Suite.

Steps for Adding Image Watermark to a PDF Document

  1. Create a Document object.
  2. Create a Page object and add it to the Document instance.
  3. Set the PDF version to v1.6.
  4. Create a ImageWatermark object and provide the path for the image.
  5. Add the ImageWatermark object to the Page instance.
  6. Save the PDF Document.

Sample Code - C#

Document document = new Document();
            
Page page = new Page();
document.Pages.Add(page);
            
document.PdfVersion = PdfVersion.v1_6;
            
ImageWatermark imageWm = new ImageWatermark(imagePath);
            
page.Elements.Add(imageWm);
            
document.Draw(@"Output.pdf");

How to Add Text Watermark to PDF in C#

The TextWatermark class adds Text as a watermark to a PDF. The following steps and sample code illustrate adding a Text Watermark to a PDF document using DynamicPDF Core Suite.

Steps for Adding Text Watermark to a PDF Document

  1. Create a Document object.
  2. Create a Page object and add it to the Document instance.
  3. Set the PDF version to v1.6.
  4. Create a TextWatermark object and provide a string to be displayed as watermark.
  5. Add the TextWatermark instance to the Page instance.
  6. Save the PDF Document.

Sample Code - C#

Document document = new Document();
            
Page page = new Page();
document.Pages.Add(page);
            
document.PdfVersion = PdfVersion.v1_6;
            
string text = "This is a text watermark.";
TextWatermark twm = new TextWatermark(text);
            
page.Elements.Add(twm);
            
document.Draw(@"Output.pdf");

How to Watermark a PDF in C#

An image, text, or any other element can be used as a watermark. Use a Template to add any page element as a watermark. The following steps and sample code illustrate adding a watermark using a Template to a PDF document using DynamicPDF Core Suite.

Steps for Adding Watermark to a PDF document

  1. Open the PDF using MergeDocument.
  2. Create a watermark template with an Image.
  3. Apply the Template to the PDF.
  4. Save the watermarked PDF document.

Sample Code - C#

MergeDocument document =  new MergeDocument(@"Doc Needs Watermark.pdf");
 
Image image = new Image(@"Watermark.png", 0, 0);
Template watermarkTemplate = new Template();
watermarkTemplate.Elements.Add(image);
document.Template = watermarkTemplate;
 
document.Draw(@"Watermarked Output.pdf");

GitHub Project

Clone or view the example project at GitHub. This example code is contained in the Examples/WatermarkExample.cs file.

Clone or View Example Project on GitHub

Getting Started

NuGet Package

DynamicPDF Core Suite is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET package. The easiest way to install the package is through the Visual Studio Package Manager. You can also download the package directly from NuGet.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Core Suite Information

DynamicPDF Core Suite contains over 75 page elements so you can add rich content to the PDFs you create:

  • Images
  • Text Objects (TextArea and Label)
  • HTML
  • Barcodes (47 types)
  • Form Fields
  • Charts

More information can be found on the DynamicPDF Core Suite webpage.

Available on Other Platforms

DynamicPDF Core Suite is available for the Java and COM/ActiveX platforms. Refer to the respective product pages for more details.

Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 18 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!