Examples

Watermark PDF (.NET Core/Framework)

Watermark can be added as Text or Image or any other page element to a PDF document.

How to Add Image Watermark to PDF in C#

The ImageWatermark class will be used to add Image Watermark. The following steps and sample code illustrate adding an Image Watermark to 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 ImageWatermark 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 is used to add Text as Watermark. 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 or text or any other element can be used as a watermark. Any page element can be added by using a Template. The following steps and sample code illustrate adding a watermark 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");

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

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!