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#

ImageWatermark class will be used to add Image Watermark. Below are the steps and sample code to add an Image Watermark to PDF document using the Generator product.

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.
  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.
  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(@"C:\Output.pdf");

How to add Text Watermark to PDF in C#

TextWatermark class will be used to add Text as Watermark. Below are the steps and sample code to add a Text Watermark to PDF document using the Generator product.

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.
  3. Set the PDF version to v1.6.
  4. Create a TextWatermark object and provide a string to be displayed as watermark.
  5. Add TextWatermark to the Page.
  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(@"C:\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. Below are the steps and sample code to watermark PDF document using the Merger product.

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(@"C:\Doc Needs Watermark.pdf");
 
Image image = new Image(@"C:\Watermark.png", 0, 0);
Template watermarkTemplate = new Template();
watermarkTemplate.Elements.Add(image);
document.Template = watermarkTemplate;
 
document.Draw(@"C:\Watermarked Output.pdf");

Getting Started

NuGet Package

DynamicPDF Merger is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET package. The Core Suite package includes Generator, Merger and ReportWriter.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Merger Information

More information can be found here:

Available in Other Platforms

Merger PDF Library is available for Java and COM/AxtiveX 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!