Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To watermark an existing PDF in C#, open it with PdfReader, create a PdfStamper, load the bitmap with Image.GetInstance, calculate coordinates from each page’s crop (or media) box, and add the image through GetOverContent(pageNumber). Loop through all pages, then close the stamper. The most common invisible-watermark bug is not a failed write: the image was positioned outside the visible page box.

This guide shows a complete iTextSharp implementation, an iText 7 approach for opacity and rotation, a PDFsharp alternative, and diagnostics for output files that grow but show no mark.

What you need before writing code

  • A .NET project that can read and write the source PDF and access the image file (PNG, JPEG or another format supported by your chosen library).
  • A writable output path different from the input path. Writing over an open input stream can fail or produce a partially written file.
  • A placement policy: corner logo, centered diagonal mark, or a repeated tiled pattern.
  • A layering policy: draw above existing page content when the mark must remain visible, or below it when the original text and images should cover the watermark.

Package names and licensing depend on the iText generation and edition you select. Verify the package version and licensing terms for your deployment before shipping; the examples below describe APIs, not current commercial terms.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTextSharp: watermark every page of an existing PDF

The following complete example uses the classic iTextSharp API. It reads each page’s crop box and falls back to its media box, scales the image to a controlled size, and keeps the logo inside the visible page area.

#1 Best Overall
MobiPDF Ultimate - All-in-One PDF Reader & Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | 1-Year Subscription | 1 Windows PC + 2 Mobile Devices | 1 User
  • EDIT text, images & designs in PDF documents. ORGANIZE PDFs. Convert PDFs to Word, Excel & ePub.
  • READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.
  • CREATE, COMBINE, SCAN and COMPRESS PDFs.
  • FILL forms & Digitally Sign PDFs. PROTECT and Encrypt PDFs.
  • 1 Year License for 1 Windows & 2 Mobile (Android and/or iOS) devices.
using System;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;

public static class PdfWatermarker
{
    public static void AddImageWatermark(
        string inputPdf,
        string outputPdf,
        string imagePath)
    {
        using (var reader = new PdfReader(inputPdf))
        using (var output = new FileStream(outputPdf, FileMode.Create, FileAccess.Write))
        using (var stamper = new PdfStamper(reader, output))
        {
            var watermark = Image.GetInstance(imagePath);
            watermark.ScaleToFit(160f, 160f);

            for (var page = 1; page <= reader.NumberOfPages; page++)
            {
                var pageSize = reader.GetCropBox(page);
                if (pageSize == null || pageSize.Width <= 0 || pageSize.Height <= 0)
                    pageSize = reader.GetPageSize(page);

                const float margin = 24f;
                var x = pageSize.Left + margin;
                var y = pageSize.Bottom + margin;

                // Keep the complete image inside the crop box.
                x = Math.Max(pageSize.Left,
                    Math.Min(x, pageSize.Right - watermark.ScaledWidth));
                y = Math.Max(pageSize.Bottom,
                    Math.Min(y, pageSize.Top - watermark.ScaledHeight));

                watermark.SetAbsolutePosition(x, y);
                stamper.GetOverContent(page).AddImage(watermark);
            }
        }
    }
}

Call it with paths such as AddImageWatermark("input.pdf", "watermarked.pdf", "logo.png"). NumberOfPages is one-based, so the loop starts at 1. GetOverContent places the image in front of the existing page content.

Center the image instead of using a corner

After scaling, calculate the center from the page box rather than using fixed coordinates:

var x = pageSize.Left + (pageSize.Width - watermark.ScaledWidth) / 2f;
var y = pageSize.Bottom + (pageSize.Height - watermark.ScaledHeight) / 2f;
watermark.SetAbsolutePosition(x, y);

Place a diagonal watermark

Use a local transformation around the image. In iTextSharp, obtain the over-content canvas, save its state, apply a rotation or concatenated matrix, add the image, and restore the state. Saving and restoring prevents the transform from affecting later page operations. If your project needs precise diagonal placement, calculate the transformed image bounds first; a rotated rectangle can extend beyond the page even when its unrotated coordinates fit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why the PDF grows but the watermark is invisible

An increased file size only proves that image and content objects were written. It does not prove that those objects fall inside the page’s visible area. PDF coordinates are measured from the page’s coordinate system, and pages can have non-zero lower-left coordinates or crop boxes smaller than their media boxes.

Check the page boxes

  • Use the crop box for the area readers normally see.
  • If no usable crop box exists, use the media box.
  • Keep the image’s complete width and height between the box’s left/right and bottom/top values.
  • Do not assume every page has the same size; mixed A4, Letter, landscape and custom pages are common.

Check image dimensions and coordinate units

PDF coordinates are points (1/72 inch). A very large bitmap can be placed partly or wholly outside the page if you use its raw dimensions. Call ScaleToFit, then position using ScaledWidth and ScaledHeight. Also confirm that the source image is not fully transparent and that its color mode is supported by the library.

Rank #2
Scrivar PDF Pro - Organize, Edit, Compress, Convert, Merge, eSign, OCR & 30+ tools | Lifetime License
  • EVERY PDF TOOL UNLOCKED - 30+ tools in one app: edit text and images, convert, merge, split, compress, sign, OCR, redact, watermark, batch process, and more. No feature gates, no upsells, nothing held back.
  • PAY ONCE, OWN FOREVER — A one-time purchase, not a subscription. Other apps runs $240/year — Scrivar is yours for life, with free updates included.
  • UNLIMITED eSIGN, BUILT IN — Send contracts and forms for signature and track every step. Recipients sign in their browser with no account or app needed. Replace DocuSign and save hundreds a year.
  • PC, MAC, AND WEB — Install on any Win 10/11 PC or macOS 11+ Mac (Intel or Apple Silicon), or work in your browser at scrivar.com. Same tools, same account, everywhere you work.
  • OCR + FULL OFFICE CONVERSION — Turn scanned documents into searchable, selectable text, and convert PDFs to and from Word, Excel, and PowerPoint with formatting kept intact.

Check layering

If the mark is behind opaque page artwork, it may technically exist but be hidden. Use GetOverContent for a foreground mark. If you intentionally need a background mark, use the corresponding under-content API and test it against pages with large white or full-bleed images.

Make a logo translucent with iText 7

iText 7 uses PdfDocument, PdfCanvas and image data objects. Transparency belongs in an extended graphics state. Save the canvas state before applying the state and restore it afterward.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
using iText.IO.Image;
using iText.Kernel.Geom;
using iText.Kernel.Pdf;
using iText.Kernel.Pdf.Extgstate;
using iText.Kernel.Pdf.Canvas;
using iText.Layout.Element;

public static void AddTransparentWatermark(
    string inputPdf, string outputPdf, string imagePath)
{
    using var pdf = new PdfDocument(
        new PdfReader(inputPdf), new PdfWriter(outputPdf));
    var imageData = ImageDataFactory.Create(imagePath);
    var opacity = new PdfExtGState().SetFillOpacity(0.22f);

    for (int pageNumber = 1; pageNumber <= pdf.GetNumberOfPages(); pageNumber++)
    {
        var page = pdf.GetPage(pageNumber);
        Rectangle box = page.GetCropBox() ?? page.GetMediaBox();
        var canvas = new PdfCanvas(page);

        float max = 160f;
        float scale = Math.Min(max / imageData.GetWidth(),
                               max / imageData.GetHeight());
        float width = imageData.GetWidth() * scale;
        float height = imageData.GetHeight() * scale;
        float x = box.GetLeft() + (box.GetWidth() - width) / 2f;
        float y = box.GetBottom() + (box.GetHeight() - height) / 2f;

        canvas.SaveState();
        canvas.SetExtGState(opacity);
        canvas.AddImageWithTransformationMatrix(
            imageData, width, 0, 0, height, x, y, false);
        canvas.RestoreState();
    }
}

The example uses the stored page dimensions. For rotated pages, decide whether your policy follows the page’s displayed orientation or its unrotated coordinate system. Rotation-aware sizing lets you position relative to what a reader sees; unrotated sizing preserves the PDF’s stored rotation behavior. Test portrait and landscape pages together rather than assuming one orientation.

Foreground versus background watermarks

Requirement iText approach Effect
Logo must remain readable over page content GetOverContent (iTextSharp) or a page canvas used for foreground content (iText 7) Image is painted after existing content
Original content should cover the mark Use under-content/background operations Image is painted before existing content
Mark should be faint Extended graphics state with reduced fill opacity Underlying text remains visible through the image

Do not combine a low opacity value with a background layer and conclude that transparency failed: both choices can make the result difficult to see.

PDFsharp and PdfSharpCore alternative

PDFsharp-style APIs use XImage for bitmap files and XGraphics for page drawing. A typical pattern opens or imports a PDF page, creates graphics with XGraphicsPdfPageOptions.Prepend for a background mark, and calls DrawImage. Microsoft examples use the same XImage/XGraphics model.

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

var document = PdfReader.Open("input.pdf", PdfDocumentOpenMode.Modify);
using var image = XImage.FromFile("logo.png");
foreach (var page in document.Pages)
{
    using var graphics = XGraphics.FromPdfPage(
        page, XGraphicsPdfPageOptions.Prepend);
    var margin = 24;
    var width = 140.0;
    var height = width * image.PixelHeight / image.PixelWidth;
    graphics.DrawImage(image, margin, margin, width, height);
}
document.Save("watermarked.pdf");

Use an append/over option when the mark must be in front. Exact option names and behavior vary between PDFsharp and PdfSharpCore versions, so check the package’s API for your target framework. Compared with iText, the important decisions remain the same: derive coordinates from each page, choose a layer deliberately, handle rotation, and provide a transparency mechanism supported by the selected version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Handling rotated and differently sized pages

  1. Read the crop box for the current page, falling back to the media box.
  2. Inspect the page rotation value and choose a policy: visual orientation (rotate coordinates with the page) or stored orientation (place in unrotated coordinates).
  3. Compute the image rectangle after scaling, then clamp its x and y values so all four edges remain in the chosen box.
  4. Test a document containing portrait, landscape, rotated, cropped and custom-size pages.

A single hard-coded (x, y) that looks correct on an A4 page is not a portable watermark algorithm.

Production checklist

  • Write to a new output file and close/dispose the reader, stamper, streams and graphics objects.
  • Validate that the input PDF and image exist and that the process has read/write permission.
  • Use a bounded image size; do not decode an unnecessarily huge bitmap for a small logo.
  • Preserve the original PDF’s page count, crop boxes, rotation and metadata unless your workflow intentionally changes them.
  • Open the output in at least two PDF viewers and inspect pages with different orientations.
  • For sensitive documents, consider whether embedding the image creates a new asset that must be retained or protected.
  • Run a visual test as well as a structural test. File size, page count and successful parsing cannot establish visibility.

Troubleshooting common failures

Output file is larger, but no watermark appears

First inspect crop/media coordinates and image bounds. Move the image temporarily to the page center, use full opacity, and use the over-content layer. If it appears, restore your intended position and opacity one variable at a time.

The watermark appears on some pages only

Your fixed coordinates probably fall outside smaller or offset boxes. Recalculate from each page’s crop/media box inside the loop and clamp against the scaled dimensions.

The watermark is clipped

The image rectangle exceeds the right or top edge, or a rotation transform extends its bounds. Reduce the scale, add margins, and calculate transformed bounds before committing the position.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Corel PDF Fusion - PDF Creator Toolkit [PC Disc]
  • Assemble, edit, and create PDFs with this easy to use, all in one PDF creator
  • Open and view over 100 file types, without purchasing additional software
  • Drag and drop multiple different file types into one PDF document
  • Easily add new text and comments to PDFs
  • Share your created documents with anyone in PDF, PDF/A, XPS or Microsoft Word formats

The logo is opaque or too faint

PNG alpha alone is not a reliable cross-library opacity control. In iText 7 set an extended graphics state fill opacity and restore the canvas state. In iTextSharp, use the transparency facilities available in the exact package/version; otherwise prepare a semitransparent source image and verify the result in multiple viewers.

Input cannot be opened or output cannot be saved

Check that the input is a valid, non-encrypted PDF, that another process is not locking it, and that the destination directory is writable. Encrypted PDFs may require the correct password and permission handling.

Watermark orientation is surprising

Determine whether your coordinates are based on unrotated page geometry or the reader-facing orientation. Apply one policy consistently and test pages with 90-, 180- and 270-degree rotation values.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your workflow also needs screenshots of web pages or rendered previews, ScreenshotNeo provides a single HTTP request instead of maintaining a browser capture stack. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers report the page verdict and billing result. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For API parameters, PDF options and the full 63-option surface, see the ScreenshotNeo documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The free plan includes 1,000 screenshots each month with no card. Paid plans start at $5 for 3,000 shots; yearly billing provides two months free. Create a free ScreenshotNeo account to try it.

Best Value
MobiOffice Lifetime 4-in-1 Productivity Suite for Windows | Lifetime License | Includes Word Processor, Spreadsheet, Presentation, Email + Free PDF Reader
  • Not a Microsoft Product: This is not a Microsoft product and is not available in CD format. MobiOffice is a standalone software suite designed to provide productivity tools tailored to your needs.
  • 4-in-1 Productivity Suite + PDF Reader: Includes intuitive tools for word processing, spreadsheets, presentations, and mail management, plus a built-in PDF reader. Everything you need in one powerful package.
  • Full File Compatibility: Open, edit, and save documents, spreadsheets, presentations, and PDFs. Supports popular formats including DOCX, XLSX, PPTX, CSV, TXT, and PDF for seamless compatibility.
  • Familiar and User-Friendly: Designed with an intuitive interface that feels familiar and easy to navigate, offering both essential and advanced features to support your daily workflow.
  • Lifetime License for One PC: Enjoy a one-time purchase that gives you a lifetime premium license for a Windows PC or laptop. No subscriptions just full access forever.

Frequently Asked Questions

Can I watermark only selected PDF pages?

Yes. Replace the loop’s full page range with the specific one-based page numbers you want, while retaining per-page box and rotation calculations.

Should I embed a watermark in the PDF content or use an annotation?

The image-stamping methods here merge image content into each page. An annotation is a different model that can be hidden, removed or handled differently by viewers, so choose it only when that interaction is required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Will stamping invalidate a digital signature?

Changing signed PDF bytes normally invalidates an existing signature. Preserve the original signed file and apply a watermark before signing, or use a signature workflow designed for permitted incremental changes.

The Bottom Line

A dependable C# watermark routine is page-aware: use crop/media boxes, scale and clamp the image, choose foreground or background deliberately, apply opacity through a graphics state when available, and test rotated and mixed-size pages. A growing output file is not proof that the mark is visible.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.