May 23, 2022

Add Watermarks to PDFs, Images or Videos

As of now there is a new Watermark API for the CloudConvert service. This new feature allows it to add watermarks or stamps to PDF documents, to images (PNG, JPG...) or videos (MP4, MOV...).

Both adding simple texts or any images as watermark is supported. A typical use case would be to add your company name or logo to files.

Adding Watermark Text

As a first example, we would like to add a red "Top Secret" watermark above an example PDF file. Therefore, we do send the following payload to the https://api.cloudconvert.com/v2/jobs endpoint:

{
    "tasks": {
        "import-file": {
            "operation": "import/url",
            "url": "https://cloudconvert-blog.s3.eu-central-1.amazonaws.com/public/test-files/zombies.pdf"
        },
        "add-watermark": {
            "operation": "watermark",
            "input": [
                "import-file"
            ],
            "input_format": "pdf",
            "layer": "above",
            "text": "Top Secret",
            "font_size": 100,
            "font_color": "#ff0400",
            "font_name": "Helvetica Bold",
            "position_vertical": "center",
            "position_horizontal": "center",
            "opacity": 50,
            "rotation": -45
        },
        "export-watermarked-file": {
            "operation": "export/url",
            "input": [
                "add-watermark"
            ],
        }
    }
}

The job contains 3 tasks:

  1. Importing the input PDF file.
  2. Adding the watermark by setting the text, font size, font name and other parameters.
  3. And the export task which creates a public URL to the output file.

Adding Watermark Images

Now we are adding a logo PNG image to the bottom right of a PDF file.

Therefore, we do send the following payload to the https://api.cloudconvert.com/v2/jobs endpoint:

{
    "tasks": {
        "import-file": {
            "operation": "import/url",
            "url": "https://cloudconvert-blog.s3.eu-central-1.amazonaws.com/public/test-files/zombies.pdf"
        },
        "import-logo": {
            "operation": "import/url",
            "url": "https://cloudconvert-blog.s3.eu-central-1.amazonaws.com/public/test-files/logo.png"
        },
        "add-watermark": {
            "operation": "watermark",
            "input": [
                "import-file"
            ],
            "input_format": "pdf",
            "layer": "above",
            "image": [
                "import-logo"
            ],
            "image_width": 500,
            "position_vertical": "bottom",
            "position_horizontal": "right",
            "margin_vertical": 25,
            "margin_horizontal": 25,
            "opacity": 75
        },
        "export-watermarked-file": {
            "operation": "export/url",
            "input": [
                "add-watermark"
            ]
        }
    }
}

The job contains 4 tasks:

  1. Importing the input PDF file.
  2. Importing the logo PNG image.
  3. The watermark task which sets input to first import task and image to the second import task. Also, there are parameters for the vertical/horizontal position and the spacing to the page boundaries.
  4. The export task creates a public URL to the output file.

Of course, this feature can be combined with other operations. For example, you could first convert files from Word to PDF and then add the watermark within a single job. Also, this can be used together with converting videos or creating thumbnails.

Checkout the full documentation of the watermark operation. The Job Builder has been updated to generate ready-to-use API payloads and code snippets for the watermark feature.