Blog post

Document watermarking 101: Enhancing security and branding with PDF SDKs

In this blog post, explore how you can leverage PDF SDKs, like Nutrient, to seamlessly add customized watermarks to PDFs and images, ensuring intellectual property protection while maintaining brand integrity. Whether you're working with web or mobile applications, Nutrient's watermarking tools offer the flexibility and performance you need to safeguard your content.

Illustration: Document watermarking 101: Enhancing security and branding with PDF SDKs

Watermarking is a powerful yet underutilized tool in document management. From protecting sensitive information to promoting brand visibility, adding watermarks to PDFs can address multiple challenges at once. For developers working with PDFs, mastering document watermarking is crucial for creating secure and professional documents. This post explores how to enhance security and branding through watermarking, using the robust capabilities of Nutrient PDF SDK.

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 serves various purposes, 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 for automated processing.

Watermarking enhances document security, protects intellectual property, ensures compliance, and strengthens branding. It’s a versatile tool in modern document management systems.

Why document watermarking matters

This section provides more detail about why watermarking is important and what purpose it fulfills.

1. Enhanced document security

Watermarks act as visible deterrents against unauthorized distribution. Whether you’re sharing contracts, confidential reports, or invoices, a well-placed watermark can help:

  • Identify ownership of a document.

  • Deter unauthorized copying or redistribution.

  • Comply with regulatory standards for sensitive documents.

2. Effective branding

A watermark can reinforce your brand identity by incorporating logos, taglines, or other elements directly into documents. This ensures:

  • Consistent branding across all document types.

  • Increased visibility and professionalism in external communication.

3. Compliance and regulation

Watermarking helps meet organizational or legal requirements for document labeling, especially in industries like healthcare, finance, and legal services.

Adding watermarks with Nutrient PDF SDK

Nutrient PDF SDK simplifies the watermarking process with cross-platform support and customizable features for developers. Here’s why it stands out:

  • Flexible customization — Add text or image watermarks with dynamic positioning, opacity, and rotation options.

  • Cross-platform support — Available for Web, iOS, and Android, ensuring seamless integration into diverse workflows.

  • High performance — Optimize large-scale document processing without compromising speed or quality.

Watermarking on different platforms

The following sections contain detailed examples and comparisons of how to use Nutrient’s products for PDF watermarking.

1. Document Engine

Nutrient’s 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.

Steps to add watermarks

  1. Set up Document Engine

Ensure Document Engine is running and ready to accept requests.

  1. 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.

  1. Flatten the annotations

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

Examples

Watermarking a file on disk

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

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:

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:

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 and get 100 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.

Nutrient Web SDK supports applying watermarks to PDFs using JavaScript. Developers can customize the text, position, and style to match their branding needs.

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 defines the watermark’s content and positioning, and the drawing is performed using the draw method, ensuring performance is optimized. This solution secures the PDF display without modifying the document itself.

Explore our 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 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

Product Ideal for Key strengths
Document Engine Advanced editing needs Full control, robust customization
PDF Watermark API Server-side applications Scalable, fine-grained control
Web SDK Browser-based solutions Lightweight, easy integration
Android SDK Mobile Android apps Seamless app integration
iOS SDK Mobile iOS apps Optimized for Apple devices
Document Converter Non-technical teams Quick setup, low-code environment

Benefits of using Nutrient PDF SDK for watermarking

  • Developer-friendly — Streamlined APIs reduce complexity and accelerate implementation.

  • Custom branding — Tailor watermarks to align with organizational branding and user preferences.

  • Scalable solutions — Handle high-volume document watermarking efficiently.

Take the next step

Ready to start watermarking your PDFs? Nutrient PDF SDK makes it simple and effective.

Conclusion

Watermarking is a powerful tool for enhancing document security and branding. Explore Nutrient’s guides and APIs to start integrating watermarking into your workflows today.

With the help of Nutrient PDF SDK, developers have a robust set of tools at their disposal to easily integrate watermarking into their workflows, offering a seamless experience across various platforms. By leveraging the capabilities of Document Engine, DWS API, Web SDK, Android SDK, iOS SDK, and Document Converter, you can customize and enhance your PDF documents to meet the security and branding needs of your organization.

Watermarking doesn’t just protect documents — it elevates their impact. By leveraging the features of Nutrient PDF SDK, you can seamlessly integrate watermarking into your workflows and deliver secure, branded documents with confidence.

FAQ

Here are a few frequently asked questions about watermarking.

What is Nutrient’s watermarking solution? Nutrient’s watermarking solution allows you to add customized watermarks to your PDFs and documents to ensure brand protection and intellectual property security. It can be seamlessly integrated into your application with the Nutrient SDK.
Can I add text or image watermarks with Nutrient’s watermarking product? Yes, Nutrient’s watermarking tool allows you to add both text and image-based watermarks. You can fully customize the position, opacity, rotation, and text of your watermark to suit your product’s needs.
Is Nutrient’s watermarking product suitable for mobile applications? Yes, Nutrient’s watermarking product can be integrated into mobile apps for both Android and iOS platforms. It ensures your documents and PDFs are secure with branded watermarks directly within your mobile applications.
Does Nutrient offer watermarking for images and documents? Nutrient’s watermarking solution is versatile and can be applied to various product types, including images, PDFs, and documents. It helps secure your content across multiple formats.
Will using Nutrient’s watermarking affect my document’s performance? No, Nutrient’s watermarking solution is optimized to apply watermarks efficiently without compromising document performance, quality, or speed.
Author
Hulya Masharipov
Hulya Masharipov Technical Writer

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

Free trial Ready to get started?
Free trial