PDF Watermark SDK

Watermarking is the process of applying an irremovable, transparent annotation to a document’s pages. Processor lets you watermark documents via the watermark operation.

Adding a watermark requires you to provide the annotation object, which describes the look of the watermark. You can use any kind of annotation.

Note that to effectively make a watermark irremovable, you must also flatten the document’s annotations.

Before you get started, make sure Processor is up and running.

Watermarking a File on Disk

Send a request to the /process endpoint, attaching an input file and the operations JSON:

curl -X POST http://localhost:5000/process \
  -F file=@/path/to/example.pdf \
  -F operations='{
  "operations": [
    {
      "type": "watermark",
      "pageIndexes": "all",
      "annotation": {
        "v": 1,
        "type": "pspdfkit/stamp",
        "stampType": "TopSecret",
        "bbox": [
          272,
          371,
          100,
          50
        ],
        "opacity": 0.25
      }
    },
    {
      "type": "flattenAnnotations"
    }
  ]
}' \
  -o result.pdf
POST /process HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary

--customboundary
Content-Disposition: form-data; name="file"; filename="example.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="operations"
Content-Type: application/json

{
  "operations": [
    {
      "type": "watermark",
      "pageIndexes": "all",
      "annotation": {
        "v": 1,
        "type": "pspdfkit/stamp",
        "stampType": "TopSecret",
        "bbox": [
          272,
          371,
          100,
          50
        ],
        "opacity": 0.25
      }
    },
    {
      "type": "flattenAnnotations"
    }
  ]
}
--customboundary--

This will add a “TOP SECRET” stamp on all the pages and flatten annotations so that the stamp cannot be erased.

Watermarking a File from URL

Send a request to the /process endpoint, attaching a URL pointing to an input file and the operations JSON:

curl -X POST http://localhost:5000/process \
  -F url=https://pspdfkit.com/downloads/examples/paper.pdf \
  -F operations='{
  "operations": [
    {
      "type": "watermark",
      "pageIndexes": "all",
      "annotation": {
        "v": 1,
        "type": "pspdfkit/stamp",
        "stampType": "TopSecret",
        "bbox": [
          272,
          371,
          100,
          50
        ],
        "opacity": 0.25
      }
    },
    {
      "type": "flattenAnnotations"
    }
  ]
}' \
  -o result.pdf
POST /process HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary

--customboundary
Content-Disposition: form-data; name="url"

https://pspdfkit.com/downloads/examples/paper.pdf
--customboundary
Content-Disposition: form-data; name="operations"
Content-Type: application/json

{
  "operations": [
    {
      "type": "watermark",
      "pageIndexes": "all",
      "annotation": {
        "v": 1,
        "type": "pspdfkit/stamp",
        "stampType": "TopSecret",
        "bbox": [
          272,
          371,
          100,
          50
        ],
        "opacity": 0.25
      }
    },
    {
      "type": "flattenAnnotations"
    }
  ]
}
--customboundary--

This will add a “TOP SECRET” stamp on all the pages and flatten annotations so that the stamp cannot be erased.

We use cookies to improve your experience and for marketing. Learn more in our privacy policy.