How to Watermark PDFs using images

Learn how to add image watermarks to PDFs using a simple API-based approach.

Overview

In this guide, we’ll walk through a simple image watermark example and show how to control the watermark size and opacity.

Prerequisites

Before you start, make sure you have:

  • The PDF file you want to watermark.
  • A watermark image in .png, or .jpeg, or .jpg.
  • A PDFGate API key (you can get one from the dashboard for free).

Image watermark example

On this example, we will use the parameters listed below from the Watermark PDF API endpoint. You can explore more customization options in the Watermark API docs and check our Text Watermarking guide for additional examples.

  • file: The bytes of the PDF file you want to watermark. Alternatively, if you have already generated a file using our HTML to PDF API, you can use the documentId parameter and send the ID instead of the file bytes.
  • watermark: The watermark image file in bytes (.png, .jpeg, .jpg).
  • type: Here we will define the type of the watermark. We will set the value to image on this example.
  • opacity: On this example, we will set the opacity of the watermark to 0.2.
  • imageWidth: Sets the watermark image width in points.
  • imageHeight: Sets the watermark image height in points.
CURL
NODE.JS
copy-integration-source-code-icon
curl -X POST "https://api.pdfgate.com/watermark/pdf" \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "file=@YOUR_FILE.pdf" \ -F "watermark=@YOUR_WATERMARK_IMAGE.png" \ -F "type=image" \ -F "opacity=0.2" \ -F "imageWidth=180" \ -F "imageHeight=150" \ --output watermarked.pdf