IRONSOFTWAREHOME
Watermarking
using IronPdf;

// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();

var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs("watermarked.pdf");
Imports IronPdf

' Stamps a Watermark onto a new or existing PDF
Dim renderer = New ChromePdfRenderer()

Dim pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center)
pdf.SaveAs("watermarked.pdf")
NuGet Download
Install-Package IronPdf
Watermarking

Watermarking

IronPDF provides methods to 'watermark' PDF documents with HTML.

Using the ApplyWatermark method, developers can add an HTML-based watermark to a PDF file. As shown in the example above, the HTML code for the watermark goes as the first argument to the method. Additional arguments to ApplyWatermark control the opacity, rotation, and alignment of the watermark.

Use the ApplyWatermark method for a quick way to overlay an HTML watermark on a PDF. For example, use ApplyWatermark to:

  • Add HTML (text or image) watermarks to PDFs
  • Apply the watermark across the pages of the PDF
  • Set the opacity of the watermark
  • Adjust the rotation and alignment of the watermark

Example C# Code to Apply a Watermark Using IronPDF

Ensure you have installed the IronPDF library in your project. You can find more detailed instructions on the IronPDF NuGet package page.

Explanation of the Code:

  • We start by importing the IronPdf library, which provides all necessary classes and methods for PDF manipulation.
  • A PDF document is created or loaded using PdfDocument.FromFile, specifying the file path of the existing PDF.
  • HTML content is defined for the watermark. In this case, the watermark displays "Confidential" with specific styling.
  • The ApplyWatermark method is used to overlay the watermark on the PDF. Its arguments allow for customization:
    • The first argument is the HTML content of the watermark.
    • opacity: Determines the transparency of the watermark.
    • The vertical and horizontal alignment arguments position the watermark on the page.
  • Finally, the SaveAs method exports the modified PDF to a new file.

In conclusion, the IronPDF ApplyWatermark method allows for straightforward watermarking of PDF documents using HTML. This approach is flexible, accommodating various customization needs for positioning, styling, and opacity of watermarks.

Explore Custom Watermarking with IronPDF
View on GitHub

Ready to Get Started?

Nuget Downloads 20,389,208Version:2026.8just released

Key in blue circle

Get your free 30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge related to IronPDF Product Demo

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required