Skip to footer content
PRODUCT COMPARISONS

Explore the Best Alternatives for PDFsharp Add Watermark to PDF

Adding watermarks to PDFs is a common requirement for document security, branding, and version control. Whether marking documents as confidential, branding official reports, or preventing unauthorized reproduction, watermarking is an essential feature.

In C#, developers have multiple libraries to choose from, with IronPDF and PDFSharp being two of the most popular options. However, their approaches, ease of use, performance, and licensing structures differ significantly. This article provides a detailed comparison between IronPDF and PDFsharp for adding watermarks to existing PDFs, offering insights into their functionalities, implementation processes, and customization capabilities.

By the end of this article, you will have a clear understanding of which library best suits your project’s needs based on ease of use, performance, and feature availability.

Understanding PDF Watermarking

What is a Watermark?

A watermark is a graphical or textual overlay on a document that serves as an identifier, deterrent, or branding element. Watermarks can be visible or invisible, depending on their purpose.

Types of Watermarks

  • Text Watermark – Typically a semi-transparent overlay with a message like "CONFIDENTIAL" or "DRAFT."
  • Image Watermark – A logo, emblem, or graphic embedded into the document.
  • Transparent Watermark – A subtle branding mark that doesn’t obstruct the document’s readability.
  • Stamped Watermark – A more prominent, bold marking that ensures visibility.

Common Use Cases

  • Security & Protection – Prevent unauthorized duplication by marking documents as proprietary.
  • Branding – Add company logos or signatures to maintain brand consistency across documents.
  • Version Control – Label drafts, final versions, or document revisions.

Overview of IronPDF and PDFsharp

IronPDF

IronPDF is a premium, feature-rich .NET library designed to streamline PDF handling. It is especially useful for developers looking for easy implementation of PDF manipulation tasks, including watermarking.

Key Features:

  • Simple and intuitive API requiring minimal code.
  • Supports text and image watermarks with customization options.
  • Offers opacity control, positioning, and rotation for precise placement.
  • Compatible with .NET 6+, .NET Core, and .NET Framework.
  • Available with a perpetual licensing model for long-term use.
  • Additional capabilities include PDF annotations, HTML-to-PDF conversion, and digital signatures.

PDFsharp

PDFsharp is an open-source library that allows developers to create, edit, and manipulate PDFs in C#. While it is highly flexible, watermarking requires more manual effort compared to IronPDF.

Key Features:

  • Free and open-source, making it cost-effective for budget-conscious projects.
  • Provides low-level control over PDF drawing operations, including both outlined graphical paths and transparent graphical paths.
  • Supports both text and image watermarks but requires additional code for transformations.
  • Works with .NET Framework and .NET Core (via PDFSharpCore).
  • Lacks built-in high-level watermarking functions, requiring developers to manually implement features like opacity and rotation.

Adding a Watermark with IronPDF

IronPDF provides a simple API that enables developers to apply watermarks efficiently with just a few lines of code, making it easy to streamline your PDF watermarking tasks efficiently, without any complex or manual setups. IronPDF's watermark tool can use HTML/CSS strings for the watermark, as you will see below, giving you full control over how your watermark will appear.

Text Watermark Example

using IronPdf;

const string filename = "existing.pdf";
// Load the existing PDF file
PdfDocument pdf = PdfDocument.FromFile(filename);

// Create a simple HTML-based watermark
string watermark = "<h1 style='color:red'>Confidential!</h1>";

// Apply the watermark to the PDF
pdf.ApplyWatermark(watermark);

// Save the updated document with the applied watermark
pdf.SaveAs("watermarked.pdf");
using IronPdf;

const string filename = "existing.pdf";
// Load the existing PDF file
PdfDocument pdf = PdfDocument.FromFile(filename);

// Create a simple HTML-based watermark
string watermark = "<h1 style='color:red'>Confidential!</h1>";

// Apply the watermark to the PDF
pdf.ApplyWatermark(watermark);

// Save the updated document with the applied watermark
pdf.SaveAs("watermarked.pdf");
Imports IronPdf

Private Const filename As String = "existing.pdf"
' Load the existing PDF file
Private pdf As PdfDocument = PdfDocument.FromFile(filename)

' Create a simple HTML-based watermark
Private watermark As String = "<h1 style='color:red'>Confidential!</h1>"

' Apply the watermark to the PDF
pdf.ApplyWatermark(watermark)

' Save the updated document with the applied watermark
pdf.SaveAs("watermarked.pdf")
$vbLabelText   $csharpLabel

Explore the Best Alternatives for PDFsharp Add Watermark to PDF: Figure 3 - Text watermark output

In this code example, we see just how easy it is to apply a watermark to your existing PDF files with IronPDF. Here, we load the existing PDF using the FromFile method. Then, we create a simple string formatted as an HTML element as the watermark and apply it to the PDF using ApplyWatermark. As shown in the output image, this has added a simple text string "Confidential" as a watermark on our PDF.

Image Watermark Example

using IronPdf;

// Load the PDF document
PdfDocument pdf = PdfDocument.FromFile("existing.pdf");

// Create an HTML-based watermark containing the image
string watermark = "<img src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'>";

// Apply the watermark to the PDF with rotation and opacity
pdf.ApplyWatermark(watermark, rotation: 45, opacity: 80);

// Save the watermarked document
pdf.SaveAs("watermarked.pdf");
using IronPdf;

// Load the PDF document
PdfDocument pdf = PdfDocument.FromFile("existing.pdf");

// Create an HTML-based watermark containing the image
string watermark = "<img src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'>";

// Apply the watermark to the PDF with rotation and opacity
pdf.ApplyWatermark(watermark, rotation: 45, opacity: 80);

// Save the watermarked document
pdf.SaveAs("watermarked.pdf");
Imports IronPdf

' Load the PDF document
Private pdf As PdfDocument = PdfDocument.FromFile("existing.pdf")

' Create an HTML-based watermark containing the image
Private watermark As String = "<img src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'>"

' Apply the watermark to the PDF with rotation and opacity
pdf.ApplyWatermark(watermark, rotation:= 45, opacity:= 80)

' Save the watermarked document
pdf.SaveAs("watermarked.pdf")
$vbLabelText   $csharpLabel

Explore the Best Alternatives for PDFsharp Add Watermark to PDF: Figure 4

Adding an image as a watermark is just as easy as adding text, as they both use the same method. Just like in the text example, we create a new watermark string variable containing the HTML image tag pointing to the image URL and apply it. This time, we include customized rotation and opacity transformations.

This approach overlays an image watermark at a specified position, allowing for custom placement and transparency.

Adding a Watermark with PDFsharp

PDFsharp requires developers to manually render text and images using its GDI+ drawing API. To watermark an existing PDF file, create an XGraphics object for drawing and apply the desired content.

Text Watermark Example

using PdfSharp.Pdf;
using PdfSharp.Drawing;
using PdfSharp.Pdf.IO;

const string filename = "existing.pdf";
// Open the PDF document in modify mode
var document = PdfReader.Open(filename, PdfDocumentOpenMode.Modify);

foreach (var page in document.Pages)
{
    // Create an XGraphics object for drawing
    var gfx = XGraphics.FromPdfPage(page);

    // Move the origin to the center of the page for rotation purposes
    gfx.TranslateTransform(page.Width / 2, page.Height / 2);

    // Rotate for diagonal watermark placement
    gfx.RotateTransform(Math.Atan(page.Height / page.Width));

    // Define font and brush for drawing the watermark text
    var font = new XFont("Arial", 40);
    var brush = new XSolidBrush(XColor.FromArgb(128, XColors.Red));  // Semi-transparent red

    // Draw the watermark text centered on the page
    gfx.DrawString("WATERMARK", font, brush, new XPoint(0, 0));
}

// Save modified document
document.Save("watermarked.pdf");
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using PdfSharp.Pdf.IO;

const string filename = "existing.pdf";
// Open the PDF document in modify mode
var document = PdfReader.Open(filename, PdfDocumentOpenMode.Modify);

foreach (var page in document.Pages)
{
    // Create an XGraphics object for drawing
    var gfx = XGraphics.FromPdfPage(page);

    // Move the origin to the center of the page for rotation purposes
    gfx.TranslateTransform(page.Width / 2, page.Height / 2);

    // Rotate for diagonal watermark placement
    gfx.RotateTransform(Math.Atan(page.Height / page.Width));

    // Define font and brush for drawing the watermark text
    var font = new XFont("Arial", 40);
    var brush = new XSolidBrush(XColor.FromArgb(128, XColors.Red));  // Semi-transparent red

    // Draw the watermark text centered on the page
    gfx.DrawString("WATERMARK", font, brush, new XPoint(0, 0));
}

// Save modified document
document.Save("watermarked.pdf");
Imports PdfSharp.Pdf
Imports PdfSharp.Drawing
Imports PdfSharp.Pdf.IO

Private Const filename As String = "existing.pdf"
' Open the PDF document in modify mode
Private document = PdfReader.Open(filename, PdfDocumentOpenMode.Modify)

For Each page In document.Pages
	' Create an XGraphics object for drawing
	Dim gfx = XGraphics.FromPdfPage(page)

	' Move the origin to the center of the page for rotation purposes
	gfx.TranslateTransform(page.Width \ 2, page.Height \ 2)

	' Rotate for diagonal watermark placement
	gfx.RotateTransform(Math.Atan(page.Height \ page.Width))

	' Define font and brush for drawing the watermark text
	Dim font = New XFont("Arial", 40)
	Dim brush = New XSolidBrush(XColor.FromArgb(128, XColors.Red)) ' Semi-transparent red

	' Draw the watermark text centered on the page
	gfx.DrawString("WATERMARK", font, brush, New XPoint(0, 0))
Next page

' Save modified document
document.Save("watermarked.pdf")
$vbLabelText   $csharpLabel

This implementation manually draws a watermark on each page, requiring precise positioning and customization. While it's capable of handling the task with a similar output to the IronPDF example, PDFsharp requires more code and a more complex method to handle applying text watermarks to existing content or new PDF files.

Image Watermark Example

using PdfSharp.Pdf;
using PdfSharp.Drawing;
using PdfSharp.Pdf.IO;

// Open the existing PDF document in modify mode
var document = PdfReader.Open("sample.pdf", PdfDocumentOpenMode.Modify);

// Load the watermark image
XImage watermark = XImage.FromFile("watermark.png");

foreach (var page in document.Pages)
{
    // Create a graphics object from the page
    XGraphics gfx = XGraphics.FromPdfPage(page);

    // Draw the image watermark at the specified position and size
    gfx.DrawImage(watermark, 50, 100, watermark.PixelWidth / 2, watermark.PixelHeight / 2);
}

// Save the modified PDF document
document.Save("watermarked.pdf");
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using PdfSharp.Pdf.IO;

// Open the existing PDF document in modify mode
var document = PdfReader.Open("sample.pdf", PdfDocumentOpenMode.Modify);

// Load the watermark image
XImage watermark = XImage.FromFile("watermark.png");

foreach (var page in document.Pages)
{
    // Create a graphics object from the page
    XGraphics gfx = XGraphics.FromPdfPage(page);

    // Draw the image watermark at the specified position and size
    gfx.DrawImage(watermark, 50, 100, watermark.PixelWidth / 2, watermark.PixelHeight / 2);
}

// Save the modified PDF document
document.Save("watermarked.pdf");
Imports PdfSharp.Pdf
Imports PdfSharp.Drawing
Imports PdfSharp.Pdf.IO

' Open the existing PDF document in modify mode
Private document = PdfReader.Open("sample.pdf", PdfDocumentOpenMode.Modify)

' Load the watermark image
Private watermark As XImage = XImage.FromFile("watermark.png")

For Each page In document.Pages
	' Create a graphics object from the page
	Dim gfx As XGraphics = XGraphics.FromPdfPage(page)

	' Draw the image watermark at the specified position and size
'INSTANT VB WARNING: Instant VB cannot determine whether both operands of this division are integer types - if they are then you should use the VB integer division operator:
	gfx.DrawImage(watermark, 50, 100, watermark.PixelWidth / 2, watermark.PixelHeight / 2)
Next page

' Save the modified PDF document
document.Save("watermarked.pdf")
$vbLabelText   $csharpLabel

Explore the Best Alternatives for PDFsharp Add Watermark to PDF: Figure 6

This method places an image watermark; however, unlike IronPDF, opacity handling must be managed separately. Like the text watermark example, applying an image-based watermark onto an existing PDF with PDFsharp requires a more elaborate and intricate setup compared to IronPDF's streamlined watermarking API.

Comparing IronPDF and PDFsharp for Watermarking

Ease of Use

  • IronPDF: Provides high-level functions that simplify watermarking with minimal code. It abstracts complex operations, making it ideal for developers who need a quick and efficient solution.
  • PDFSharp: Requires manual implementation using the graphics API, which increases complexity and development time. It is better suited for developers who need fine-grained control over rendering but are comfortable with additional coding.

Performance

  • IronPDF: Optimized for high-speed PDF processing, capable of handling large documents efficiently without significant performance degradation.
  • PDFSharp: While lightweight, it may require additional optimizations for handling large PDFs. Complex watermarking tasks with multiple transformations can lead to slower performance compared to IronPDF.

Customization Options

  • IronPDF: Built-in support for opacity, rotation, positioning, and font size customization. Users can easily tweak settings without delving into complex rendering logic.
  • PDFSharp: Requires additional coding for opacity, transparency effects, and transformation handling. While powerful, it demands a higher level of customization from the developer, including using the var format for specific rendering tasks.

Compatibility

  • IronPDF: Fully compatible with .NET 6+, .NET Core, and .NET Framework, making it suitable for modern and legacy applications.
  • PDFSharp: Supports .NET Framework and .NET Core (via PDFSharpCore), but may lack certain modern features available in newer frameworks.

Licensing and Cost

  • IronPDF: A commercial product that requires a paid license but includes perpetual licensing options, customer support, and continuous updates.
  • PDFSharp: Open-source and free to use, making it a cost-effective solution for developers who prefer an unrestricted licensing model but are willing to handle their own support and updates.

Conclusion

Explore the Best Alternatives for PDFsharp Add Watermark to PDF: Figure 7

For developers who need an easy and efficient way to watermark PDFs, IronPDF is the superior choice due to its user-friendly API and built-in features. However, if budget constraints are a concern and you don’t mind writing additional code, PDFSharp is a solid open-source alternative. Ultimately, the best choice depends on your project requirements, coding expertise, and available resources.

Try IronPDF out for yourself by downloading the free trial and exploring how it can take your C# PDF projects to the next level today!

Please notePDFsharp is a registered trademark of its respective owner. This site is not affiliated with, endorsed by, or sponsored by PDFsharp. All product names, logos, and brands are property of their respective owners. Comparisons are for informational purposes only and reflect publicly available information at the time of writing.

Frequently Asked Questions

How can I add a watermark to a PDF using a .NET library?

You can add a watermark to a PDF using IronPDF by utilizing its simple API, which supports both text and image watermarks with customizable options like opacity and rotation.

What are the advantages of using a premium .NET PDF library for watermarking?

A premium .NET PDF library like IronPDF offers high-level functions for easy watermarking, compatibility with modern .NET frameworks, and additional features like PDF annotations and HTML-to-PDF conversion.

Why is watermarking important in PDF documents?

Watermarking is important for document security, branding, and version control. It helps prevent unauthorized reproduction, ensures brand consistency, and marks documents as confidential.

What are the differences between IronPDF and PDFsharp in watermarking PDFs?

IronPDF provides a more intuitive API for easy watermarking with minimal code, while PDFsharp requires more manual effort and additional coding for transformations and opacity settings.

How does IronPDF improve PDF manipulation compared to open-source options?

IronPDF offers built-in high-level functions, making it easier to perform PDF manipulations like watermarking, annotations, and conversions, which would require more complex coding in open-source options like PDFsharp.

What types of watermarks can be added to PDFs using .NET libraries?

With libraries like IronPDF, you can add text watermarks, image watermarks, and transparent watermarks, with options for customization regarding positioning, opacity, and rotation.

Is IronPDF suitable for handling large PDF documents?

Yes, IronPDF is optimized for high-speed processing and can efficiently handle large PDF documents without performance issues.

What should I consider when choosing between a premium and open-source .NET PDF library?

Consider ease of use, available features, compatibility, performance, and support. A premium library like IronPDF offers extensive features and support, whereas an open-source library like PDFsharp is free but requires more complex coding and lacks official support.

Can I use IronPDF with .NET Core?

Yes, IronPDF is compatible with .NET 6+, .NET Core, and .NET Framework, making it versatile for different development environments.

What additional functionalities does IronPDF provide beyond watermarking?

In addition to watermarking, IronPDF supports PDF annotations, HTML-to-PDF conversion, digital signatures, and more, offering comprehensive PDF manipulation capabilities.

Chipego
Software Engineer
Chipego has a natural skill for listening that helps him to comprehend customer issues, and offer intelligent solutions. He joined the Iron Software team in 2023, after studying a Bachelor of Science in Information Technology. IronPDF and IronOCR are the two products Chipego has been focusing on, but his knowledge of ...Read More