ZingPDF logo

Guide

How to add watermarks to PDFs in C#

Use Page.AddWatermarkAsync(...) when you want to mark one page, or Pdf.AddWatermarkAsync(...) when you want the same text applied across the whole document.

This is the right path when you need a simple text mark such as CONFIDENTIAL, DRAFT, or PAID.

Watermark one page

Get the page you want, add the watermark, then save the document.

using ZingPDF;

using var input = File.OpenRead("report.pdf");
using var output = File.Create("report-watermarked.pdf");
using var pdf = Pdf.Load(input);

var firstPage = await pdf.GetPageAsync(1);
await firstPage.AddWatermarkAsync("DRAFT");
await pdf.SaveAsync(output);

That writes the watermark to the selected page and leaves the rest of the document alone.

Watermark every page

If you want the same text repeated across the document, call the document-level helper instead.

using ZingPDF;

using var input = File.OpenRead("report.pdf");
using var output = File.Create("report-watermarked.pdf");
using var pdf = Pdf.Load(input);

await pdf.AddWatermarkAsync("CONFIDENTIAL");
await pdf.SaveAsync(output);

That applies the watermark across the whole document and writes the result to report-watermarked.pdf.

When the high-level watermark helper fits

The document-level helper is for one repeated text watermark across the pages of the PDF.

If you want a single status mark added to the whole file, this is the simplest path. If you need to mark one page only, call Page.AddWatermarkAsync(...). If you need custom placement logic or mixed drawing operations, move down to the page APIs.

Combining it with other document edits

Watermarking is often one step in a larger write path. You can update metadata, merge pages, or compress streams before the final save.

using var pdf = Pdf.Load(File.OpenRead("invoice-pack.pdf"));

var metadata = await pdf.GetMetadataAsync();
metadata.Title = "Invoice Pack";

await pdf.AddWatermarkAsync("PAID");
pdf.Compress(dpi: 72, quality: 75);
await pdf.SaveAsync(File.Create("invoice-pack-final.pdf"));

The watermark is just another document change in the save pipeline, so it can sit alongside other updates.

Save behavior

By default, the updated file is saved as a new incremental revision. If you need a rewritten file with only the latest live objects, call RemoveHistoryAsync() before saving.

  • The output stream for SaveAsync(...) must be writable and seekable.
  • If you save to a different stream, it must be empty.
  • If you save back to the original stream, ZingPDF appends a new revision.

Add protection before you save the final copy

A common follow-on step is watermarking the file and then writing encrypted output.

Read How to encrypt a PDF with AES in C#.

Open save docs View pricing