In general, a watermark can be described as a pattern or image, which appears superimposed on a paper when viewed. Also, it looks to the viewer as different distinct writing or image that can sit at any location on a piece of paper. In most cases, watermarks appear in the background of a paper or document. Therefore, it does not prevent the viewer from interpreting writings or images that are printed on paper. Initially, watermarks were primarily used to prevent counterfeiting. As a result, currencies, stamps, and other essential documents were made with watermarks. Now, watermarks are popularly used on electronic documents.

More often than not, most watermarks are easy to see and identify. These types of watermarks are casually used. However, some watermarks are intricately placed on documents. So, you can easily see it. Sometimes you will need special devices or fluids to see the watermark. In some cases, watermarks may glow when placed in the dark or under a special light.

History of Watermark

Before people started using watermarks on digital documents, it was used on physical paper for hundreds of years. Watermark was said to be first introduced in 1282 in olden day Italy. In the past, the creation of a watermark was not straightforward. The paper thickness had to be altered to create a watermark. Doing this produced a difference, which resulted in a watermarked paper. The paper had to be wet to carry out the watermarking. Or, at least the paper had to contain some level of moisture for the watermark process to be successful.

Now, when making physical watermarks, two main processes are used. These processes are cylinder mold and dandy roll. However, you can easily print electronic documents with watermarks. Nonetheless, various digital methods including Python can be used for watermarking digital documents.

How to Add a Watermark

PDF.co Web API can watermark or stamp your PDF with text and/or image. The text can be personalized by setting a font name, font size, text alignment, etc. You can also make it clickable and redirect your client or user to a specific page. The image can be resized. Also, you can place this watermark anywhere in the PDF.

Add Watermark to PDF in Python – Step-by-step Guide

  1. Download Source Code
  2. Install Requests Module
  3. Enter API Key
  4. Add PDF URL
  5. Add Watermark
  6. Run Program
  7. Watermark PDF Demo

In this demonstration, we will add a logo watermark to a PDF document. We will use the /v1/pdf/edit/add endpoint to add the watermark. Below is the GIF image of the input and output files.

PDF Document With And Without Watermark
PDF Document with and without Watermark

Step 1: Download Source Code

Before we begin, we highly recommend that you download or copy the Python source code that we will use in this demonstration. You can get it here.

Step 2: Install Requests Module

We will use the requests module in this sample code. If you haven’t yet, open your command line (cmd.exe) and type this command python -m pip install requests.

Install Requests Module

Step 3: Enter API Key

Let’s open our Python code. In line 6, enter your API Key inside the double-quotes. You can get your API Key in your dashboard here.

Enter PDF.co API Key

Step 4: Add PDF URL

In line 13, enter the PDF link. PDF.co Files can store your files in the cloud permanently. This storage option is available to our monthly and annual members. To learn more, check out this guide.

Add Source File URL

Step 5: Add Watermark

Now, let’s configure the image parameter for the watermark.

  • In line 25, leave the default image value.
  • In lines 26 and 27, you can set the watermark’s x and y coordinates. You can use the PDF Viewer to easily grab these numbers.
  • In lines 28 and 29, you can specify the watermark’s width and height.
  • In line 30, add the watermark’s URL.

Configure Image Parameter

Step 6: Run Program

Now run the program to see the result in your local folder.

PDF Output

Step 7: Watermark PDF Demo

Here’s the PDF.co Web API in action.

Watermark PDF Demo
Watermark PDF Demo

In this demonstration, you learned how to add a logo watermark in a PDF using Python and PDF.co Web API. You learned how to customize the watermark by changing its height and width. You also learned how to place the watermark exactly where you want it using the PDF Viewer.