0CodeKit icon

0CodeKit

A toolbox of no-code utilities

Actions132

PDF → Add Image Watermark to PDF

AI-generated

Overview

The "Add Image Watermark to PDF" operation in the PDF resource allows users to apply an image watermark onto one or more pages of a PDF document. This node is useful for branding, copyright protection, or marking documents as confidential by overlaying a semi-transparent image on top of the original PDF content.

Typical use cases include:

  • Adding company logos as watermarks to official PDF reports.
  • Marking PDFs with "Draft" or "Confidential" images.
  • Applying custom stamps or seals to invoices or contracts.

Users can specify the source PDF either via a public URL or by providing binary buffer data. Similarly, the watermark image can be supplied as a URL or as Base64-encoded image data. The watermark's position, size, opacity, rotation, and the specific pages to apply it to are all configurable.

Properties

Name Meaning
PDF URL Public URL of the PDF file to which the watermark will be applied.
PDF Buffer Binary buffer data of the PDF file as an alternative to providing a URL.
Image URL URL of the image to use as the watermark.
Image Buffer Base64-encoded image data to use as the watermark instead of an image URL.
Opacity Opacity level of the watermark image, ranging from 0.0 (fully transparent) to 1.0 (fully opaque). Default is 0.3.
Anchor Position The part of the PDF page where the watermark should be anchored. Options: Bottom Center, Bottom Left, Bottom Right, Center, Center Left, Center Right, Top Center, Top Left, Top Right. Default is Center.
Alignment The part of the watermark image that aligns with the anchor position on the page. Same options as Anchor Position. Default is Center.
X Offset Horizontal offset in points relative to the anchor position. Positive values move the watermark right; negative values move it left. Default is 0.
Y Offset Vertical offset in points relative to the anchor position. Positive values move the watermark up; negative values move it down. Default is 0.
Width Width of the watermark image in points. If only width is provided, height is calculated automatically to maintain aspect ratio. Default is 200.
Height Height of the watermark image in points. If only height is provided, width is calculated automatically. Default is 100.
Rotation Counter-clockwise rotation angle of the watermark in degrees. Default is 0 (no rotation).
Pages Specifies which pages to apply the watermark to. Supports ranges and relative page numbers, e.g., "1,3-5,^3-^1" where "^1" means last page.
File Name Desired name for the output PDF file after watermarking.
Return as URL Boolean flag indicating whether the resulting PDF should be returned as a downloadable URL (true) or as binary data (false). Required property. Default is false.

Output

The node outputs the watermarked PDF file. Depending on the "Return as URL" property:

  • If Return as URL is true, the output JSON contains a URL pointing to the downloadable watermarked PDF.
  • If false, the output includes the binary data of the watermarked PDF file.

This allows flexible downstream usage, either by downloading the file directly or passing the binary data to other nodes for further processing.

Dependencies

  • Requires access to the internet if using URLs for the input PDF or watermark image.
  • Needs an API key credential configured in n8n to authenticate requests to the external service handling the watermarking process.
  • No local PDF processing libraries are used; the operation relies on a remote API endpoint.

Troubleshooting

  • Common issues:

    • Providing both PDF URL and PDF Buffer empty or invalid will cause failure; ensure at least one valid PDF input is given.
    • Invalid or inaccessible image URL or corrupted Base64 image data will prevent watermark application.
    • Incorrect page range syntax in the "Pages" property may result in no pages being watermarked.
    • Large PDF files or images might lead to timeouts or memory issues depending on the external service limits.
  • Error messages:

    • "Invalid PDF input" — Check that the PDF URL is publicly accessible or the buffer data is correctly encoded.
    • "Image not found or invalid format" — Verify the watermark image URL or Base64 data.
    • "Page range out of bounds" — Ensure the specified pages exist in the PDF.
    • "Authentication failed" — Confirm the API key credential is properly set up in n8n.

Resolving these typically involves verifying inputs, ensuring network accessibility, and confirming correct configuration of credentials.

Links and References

Discussion