How to add watermarks to PDFs: A complete guide for developers

Table of contents

    Add text or image watermarks to PDFs for security, branding, or compliance. This guide covers implementation across Web, iOS, Android, and server-side platforms using Nutrient SDK.
    How to add watermarks to PDFs: A complete guide for developers
    TL;DR

    Add watermarks to PDFs using Nutrient SDK. This guide covers text and image watermarks, static vs. dynamic options, and code examples for Document Engine, Web SDK, iOS, and Android.

    Watermarks protect sensitive documents, reinforce branding, and help with compliance. This guide shows you how to add watermarks to PDFs using Nutrient PDF SDK across web, mobile, and server-side platforms.

    What is a watermark?

    A watermark is a piece of text, an image, or data added to a document, photo, or even a banknote to prevent unauthorized copying or misuse. It can be obvious, like a logo or stamp, or hidden within the content as invisible data.

    Watermarks help protect content, but they only work if they’re difficult to remove — otherwise, they don’t serve much of a purpose.

    Understanding document watermarking

    Document watermarking embeds a recognizable mark — visible or invisible — on a document to indicate ownership or provide additional context. Visible watermarks, such as logos or text, are directly noticeable, while invisible watermarks are hidden and can only be detected with special tools.

    Common use cases for watermarking

    Watermarking addresses a range of business and security needs across industries, including:

    • Copyright protection — Prevent unauthorized distribution or plagiarism.
    • Branding — Add company logos or taglines to reinforce identity.
    • Tracking and auditing — Identify document leaks or unauthorized sharing with dynamic information (e.g. Opened by [User] on [Date] from IP [Address]).
    • Metadata and labeling — Display associated metadata such as author, project name, due date, or compliance labels.
    • Status indicators — Mark documents with statuses like Draft, Final, or Confidential.
    • Security and compliance — Overlay user IDs, timestamps, or other details to ensure document security.
    • Legal and policy notices — Insert legal disclaimers, copyright messages, or corporate policies.
    • Machine-readable data — Embed barcodes or QR codes with our barcode scanner SDK for automated processing.

    Why use watermarks on PDFs?

    Watermarks provide practical benefits for security, branding, and compliance. Here’s how they protect your documents and support business requirements.

    1. Security

    Watermarks deter unauthorized distribution. When sharing contracts, reports, or invoices, a watermark:

    • Identifies document ownership
    • Discourages copying or redistribution
    • Helps meet regulatory requirements

    2. Branding

    Add logos or taglines directly to documents for consistent branding across all outputs.

    3. Compliance

    Industries like healthcare, finance, and legal services often require document labeling. Watermarks satisfy these requirements.

    Types of watermarks: Static vs. dynamic

    • Static watermarks — Same on every document (e.g. company logo, CONFIDENTIAL stamp). Applied uniformly.
    • Dynamic watermarks — Generated per document with variable data like usernames, timestamps, or document IDs. Useful for tracking who accessed what.

    How to add watermarks with Nutrient SDK

    Nutrient PDF SDK supports text and image watermarks across all platforms:

    • Customizable — Control position, opacity, rotation, and text styling
    • Cross-platform — Web, iOS, Android, and server-side (Document Engine)
    • Performant — Handles large-scale document processing

    Adding watermarks on different platforms

    The following sections provide platform-specific implementation guides with code examples for Document Engine, Web SDK, iOS, Android, and Document Converter.

    1. Document Engine

    Nutrient Document Engine makes it easy to watermark documents using the watermark action. You can specify options that describe the look and position of a watermark, including both text and image annotations.

    Follow these steps to watermark documents with Document Engine.

    Steps to add watermarks

    1. Set up Document Engine

      Ensure Document Engine is running and ready to accept requests.

    2. Use multipart POST requests

      Send requests to the /api/build endpoint with detailed instructions. For more information, refer to A brief tour of multipart requests.

    3. Flatten the annotations

      After applying the watermark, flatten the document’s annotations to make the watermark irremovable.

    Examples

    These examples demonstrate common watermarking scenarios using Document Engine.

    Watermarking a file on disk

    To add a TOP SECRET text watermark, use the following code:

    Terminal window
    curl -X POST http://localhost:5000/api/build \
    -H "Authorization: Token token=<API token>" \
    -F document=@/path/to/example-document.pdf \
    -F instructions='{
    "parts": [
    {
    "file": "document",
    "actions": [
    {
    "type": "watermark",
    "text": "TOP SECRET",
    "width": 100,
    "height": 200
    },
    {
    "type": "flatten"
    }
    ]
    }
    ]
    }' \
    -o result.pdf

    This request attaches an input file and specifies watermarking actions to apply.

    Adding image and text watermarks

    Here’s an example of combining an image watermark on the first page of a document and a text watermark on the last page:

    Terminal window
    curl -X POST http://localhost:5000/api/build \
    -H "Authorization: Token token=<API token>" \
    -F document=@/path/to/example-document.pdf \
    -F image-local=@/path/to/image-watermark.png \
    -F instructions='{
    "parts": [
    {
    "file": "document",
    "pages": {
    "start": 0,
    "end": 0
    },
    "actions": {
    "type": "watermark",
    "image": "image-local",
    "width": 100
    }
    },
    {
    "file": "document",
    "pages": {
    "start": 3,
    "end": 3
    },
    "actions": {
    "type": "watermark",
    "text": "TOP SECRET",
    "width": 100,
    "height": 200
    }
    }
    ],
    "actions": [
    {
    "type": "flatten"
    }
    ]
    }' \
    -o result.pdf

    Watermarking a file from a URL

    You can also use URLs to specify both the document and the image for the watermark:

    Terminal window
    curl -X POST http://localhost:5000/api/build \
    -H "Authorization: Token token=<API token>" \
    -F instructions='{
    "parts": [
    {
    "file": {
    "url": "https://www.nutrient.io/downloads/examples/paper.pdf"
    },
    "pages": {
    "start": 0,
    "end": 0
    },
    "actions": {
    "type": "watermark",
    "image": {
    "url": "https://image-url.com/path-to-image-on-internet.png"
    },
    "width": 100
    }
    }
    ],
    "actions": [
    {
    "type": "flatten"
    }
    ]
    }' \
    -o result.pdf

    When specifying URLs, ensure the image URL includes the MIME type, such as png.

    2. Nutrient DWS API — PDF watermark API

    Nutrient DWS API lets you add custom watermarks to PDF documents via an easy-to-use HTTP service.

    Benefits

    • Secure — Data isn’t stored, and all interactions are encrypted (SOC 2 compliant).
    • Simple — Quick integration with well-documented APIs.
    • Flexible — More than 30 tools for document conversion and manipulation.
    • Affordable — Pay based on credits, with transparent pricing.

    Get started

    1. Sign up for a free account(opens in a new tab) and get 200 credits.
    2. Upload files by placing your document.pdf and logo.png files in your project.
    3. Use the provided sample code in your preferred language.
    4. Download result.pdf and check for the watermark.

    Example with Node.js

    const axios = require("axios");
    const FormData = require("form-data");
    const fs = require("fs");
    const formData = new FormData();
    formData.append(
    "instructions",
    JSON.stringify({
    parts: [{ file: "document" }],
    actions: [{ type: "watermark", image: "logo", width: "25%" }],
    }),
    );
    formData.append("document", fs.createReadStream("document.pdf"));
    formData.append("logo", fs.createReadStream("logo.png"));
    (async () => {
    try {
    const response = await axios.post(
    "https://api.nutrient.io/build",
    formData,
    {
    headers: formData.getHeaders({
    Authorization: "Bearer your_api_key",
    }),
    responseType: "stream",
    },
    );
    response.data.pipe(fs.createWriteStream("result.pdf"));
    } catch (e) {
    const errorString = await streamToString(e.response.data);
    console.log(errorString);
    }
    })();
    function streamToString(stream) {
    const chunks = [];
    return new Promise((resolve, reject) => {
    stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
    stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
    stream.on("error", reject);
    });
    }

    The code uses Node.js to add a watermark to a PDF by sending a request to Nutrient DWS API with a PDF and image file, along with your API key for authentication. The watermarked PDF is saved as result.pdf after the request is processed.

    3. Web SDK

    Nutrient Web SDK allows you to add watermarks to PDFs displayed in the browser, which is useful for preventing screenshots by overlaying user-specific information, such as a username. To achieve this, use the renderPageCallback option in the pspdfkit#load() method, where you can draw the watermark on each page using the Canvas API, as shown in the example below:

    PSPDFKit.load({
    document: document,
    renderPageCallback: function (ctx, pageIndex, pageSize) {
    ctx.beginPath();
    ctx.moveTo(0, 0);
    ctx.lineTo(pageSize.width, pageSize.height);
    ctx.stroke();
    ctx.font = "30px Comic Sans MS";
    ctx.fillStyle = "red";
    ctx.textAlign = "center";
    ctx.fillText(
    `Generated for John Doe. Page ${pageIndex + 1}`,
    pageSize.width / 2,
    pageSize.height / 2,
    );
    },
    });

    This watermark only appears during viewing in the browser and doesn’t alter the original PDF document.

    4. Android SDK — Secure your PDFs with custom watermarks

    To add custom, non-removable watermarks to PDFs, use Nutrient Android SDK’s PdfDrawable API. This method allows you to overlay user-specific watermarks (e.g. name, timestamp) to discourage unauthorized sharing or screenshots. You can provide a PdfDrawableProvider that will be registered with the PdfFragment to apply the watermark, including on page thumbnails. Here’s an example of how to set this up in your PdfActivity:

    class WatermarkExampleActivity : PdfActivity() {
    private val customTestDrawableProvider: PdfDrawableProvider = object : PdfDrawableProvider() {
    override fun getDrawablesForPage(context: Context, document: PdfDocument, @IntRange(from = 0) pageIndex: Int): List<PdfDrawable> {
    return listOf(WatermarkDrawable("Watermark", PointF(350f, 350f)))
    }
    }
    override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    requirePdfFragment().addDrawableProvider(customTestDrawableProvider)
    pspdfKitViews.thumbnailBarView?.addDrawableProvider(customTestDrawableProvider)
    }
    }

    The WatermarkDrawable class handles content and positioning. The watermark appears onscreen but doesn’t modify the PDF file.

    Explore the Android demo:

    5. iOS SDK

    Nutrient iOS SDK allows you to add a permanent watermark to all pages of a document using the Processor API. The following example shows how to apply a watermark to every page:

    let configuration = Processor.Configuration(document: document)!
    configuration.drawOnAllCurrentPages { context, pageIndex, pageRect, renderOptions in
    let text = "Watermark on Page \(pageIndex + 1)"
    context.translateBy(x: 0, y: pageRect.size.height / 2)
    context.rotate(by: -.pi / 4)
    let attributes: [NSAttributedString.Key: Any] = [
    .font: UIFont.boldSystemFont(ofSize: 30),
    .foregroundColor: UIColor.red.withAlphaComponent(0.5)
    ]
    text.draw(with: pageRect, options: .usesLineFragmentOrigin, attributes: attributes, context: nil)
    }
    let processor = Processor(configuration: configuration, securityOptions: documentSecurityOptions)
    try processor.write(toFileURL: processedDocumentURL)

    This method creates a new PDF with the watermark applied to all pages, which will remain even in other PDF viewers.

    For a temporary watermark that won’t be saved to disk, use the following:

    let renderBlock: PSPDFRenderDrawBlock = { context, pageIndex, pageRect, renderOptions in
    let text = "Temporary Watermark on Page \(pageIndex + 1)"
    context.translateBy(x: 0, y: pageRect.size.height / 2)
    context.rotate(by: -.pi / 4)
    let attributes: [NSAttributedString.Key: Any] = [
    .font: UIFont.boldSystemFont(ofSize: 30),
    .foregroundColor: UIColor.red.withAlphaComponent(0.5)
    ]
    text.draw(with: pageRect, options: .usesLineFragmentOrigin, attributes: attributes, context: nil)
    }
    document.updateRenderOptions(for: .page) {
    $0.drawBlock = renderBlock
    }

    This approach adds a watermark for display, but it won’t be saved in the document. For more details, refer to DrawOnPagesExample.swift(opens in a new tab) in the Nutrient Catalog.

    Explore our iOS demo:

    6. Advanced watermarking solutions with Nutrient Document Converter

    Nutrient Document Converter provides powerful watermarking capabilities for SharePoint, Power Automate, and Document Converter Services. These features ensure document security, enhance compliance, and support branding by adding dynamic, customizable watermarks to a wide variety of file types.

    Watermarking in SharePoint

    Add watermarks directly to your documents in SharePoint Online and on-premises environments using the following solutions.

    Automate the addition of watermarks such as text, images, barcodes, or QR codes. Place watermarks behind or in front of document content, and apply them to specific pages or page ranges.

    Integrate watermarking into advanced workflows using Nintex for SharePoint. Apply elements like shapes, text, or logos as watermarks, and manage multiple watermark actions with the composite watermark feature.

    Apply watermarks directly from the SharePoint interface for documents or list item attachments. Options include:

    • Dynamic watermarks — Custom user-specific watermarks that display when a document is opened.
    • Page-specific placement — Apply watermarks to odd/even pages, page intervals, or specific orientations (portrait or landscape).

    Watermarking with Power Automate

    Document Converter integrates seamlessly with Power Automate to enable watermarking within automated workflows.

    • Dynamic watermark content:

    Automatically include dates, times, user details, or metadata from connected systems.

    • Flexible options:

    Add text, images, barcodes, or shapes as watermarks, and control placement on single or multiple pages.

    • Custom automation:

    Easily configure workflows to apply watermarks dynamically during document processing, ensuring consistency and compliance.

    PDF watermark API for developers

    For custom solutions, Nutrient offers a robust PDF watermark API that allows developers to embed watermarks programmatically.

    • Dynamic customization:

    Add metadata, page numbers, user-specific data, and branding elements such as company logos or legal disclaimers.

    • Advanced features:
      • Place watermarks on specific pages (e.g. odd, even, intervals, portrait, or landscape).
      • Insert a variety of elements like text, QR codes, images, and barcodes.
      • Add machine-readable data for auditing or compliance.
    • Developer integration:

    Access sample code in C#, Java, .NET Core, PHP, and JavaScript to simplify implementation.

    Contact our Sales team for more information on Nutrient’s low-code solutions for watermarking.

    Comparison of Nutrient products

    ProductIdeal forKey strengths
    Document EngineAdvanced editing needsFull control, robust customization
    PDF watermark APIServer-side applicationsScalable, fine-grained control
    Web SDKBrowser-based solutionsLightweight, easy integration
    Android SDKMobile Android appsSeamless app integration
    iOS SDKMobile iOS appsOptimized for Apple devices
    Document ConverterNon-technical teamsQuick setup, low-code environment

    Get started with watermarks

    FAQ

    How do I add watermarks to a PDF?

    Use Nutrient SDK’s watermark API. You can add text or image watermarks with custom positioning, opacity, and rotation. See the code examples above for Document Engine, Web SDK, iOS, and Android.

    Can I add both text and image watermarks?

    Yes. Nutrient SDK supports text watermarks (e.g. CONFIDENTIAL, usernames, timestamps) and image watermarks (e.g. logos, stamps). You can combine both on the same document.

    What’s the difference between static and dynamic watermarks?

    Static watermarks are the same on every document (e.g. a company logo). Dynamic watermarks include variable data like usernames, timestamps, or document IDs, which are useful for tracking and security.

    Can I add watermarks on mobile apps?

    Yes. Nutrient SDK supports watermarks on iOS and Android. The watermark appears during viewing but doesn’t modify the original PDF unless you flatten it.

    How do I make watermarks permanent?

    Use the “flatten” action after applying the watermark. This burns the watermark into the PDF so it can’t be removed, even in other PDF viewers.

    Hulya Masharipov

    Hulya Masharipov

    Technical Writer

    Hulya is a frontend web developer and technical writer who enjoys creating responsive, scalable, and maintainable web experiences. She’s passionate about open source, web accessibility, cybersecurity privacy, and blockchain.

    Explore related topics

    Try for free Ready to get started?