How to Create Custom C# Watermark PDF

Updated February 28, 2023

A custom watermark is a personalized background image or text overlay added to a document or image. Custom watermarks serve various purposes, including branding with logos or names, enhancing security with labels like 'Confidential,' ensuring copyright protection, and indicating document status. Adding a custom watermark to a PDF page can be very useful for any of these reasons.

Custom watermarks can include text, images, or both, and their opacity can be adjusted for versatility in personalizing, securing, and contextualizing PDFs.

IronPDF offers an easy way to adding a watermark to PDF documents for whatever your needs may be. The add watermark to PDF feature accepts an HTML string to generate the watermark, which is capable of using all HTML features as well as CSS styling.

How to Apply Custom C# Watermark PDF document

  1. Download the C# library to apply custom watermarks
  2. Render a new or import existing PDF files
  3. Configure the HTML string to be used as a watermark
  4. Use the 'ApplyWatermark'method to apply a watermark
  5. Specify rotation, opacity, and location on the document as required

Apply PDF Watermarks Example

To add a custom watermark to your PDF document, simply utilize the **ApplyWatermark** method to apply a watermark to either newly generated PDF files or an existing PDF file. This method accepts an HTML string as the watermark, enabling it to have all the features that HTML offers, including CSS styling.

Let's use both an image and text as our watermark in the example below. Please note that the watermark will be applied to all the pages, it's not possible to apply the watermark to specific pages.

This is a very easy way to add image watermark text from a variety of image formats, such as PNG or JPEG, and text watermark with a custom font.

Watermark Opacity and Rotation

To start with, add a watermark with the default opacity of 50%. This level can be further configured according to the user's requirements.

When it comes to editing the rotation of the watermark, there is an overload of the **ApplyWatermark** method that also takes rotation as a parameter. By specifying the 'rotation:' and 'opacity:', we can adjust these two parameters.

Watermark Location on PDF file

To specify the location of the watermark, we will use a 3x3 grid divided into 3 columns horizontally and 3 rows vertically. The horizontal options are left, center, and right, while the vertical options are top, middle, and bottom. With this configuration, we can set 9 different locations on each page of the document. Please refer to the image below for a visual representation of this concept.

To add a watermark to a specific location, utilize the **VerticalAlignment** and **HorizontalAlignment** enums in the IronPdf.Editing namespace.

No matter if it's adding a watermark to a new document or existing PDF files, IronPDF offers an easy way to add custom watermarks to PDF files, whether its an image watermark, a text watermark, or both. Start using IronPDF for all your documentation needs today with its free trial, a risk-free way to explore everything that IronPDF has to offer, an easy way to see just how IronPDF could be suited for your needs and if IronPDF proves to be an invaluable addition to your work, you can purchase a license to continue getting the best out of what IronPDF has to offer.

Purchase Order Software
Machine Learning Case

Get your free white paper

Thank you,

The email with download link will sent to you shortly.