PDF tools

Secure

protect, unlock, watermark, page-numbers.

Four operations to lock down and stamp documents. All take a base64 pdf and return the resulting PDF binary.

PDF=$(base64 -w0 input.pdf)     # macOS: base64 -i input.pdf

Protect (encrypt)

POST /v1/pdf/protect — password-encrypt a PDF:

curl -X POST https://api.pdf-forge.dev/v1/pdf/protect \
  -H "Authorization: Bearer $PDFFORGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"pdf\": \"$PDF\", \"password\": \"s3cret\"}" \
  --output protected.pdf

Unlock (decrypt)

POST /v1/pdf/unlock — remove the protection, given the correct password:

curl -X POST https://api.pdf-forge.dev/v1/pdf/unlock \
  -H "Authorization: Bearer $PDFFORGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"pdf\": \"$PDF\", \"password\": \"s3cret\"}" \
  --output unlocked.pdf

A wrong password returns 400 invalid_request.

Watermark

POST /v1/pdf/watermark — stamp text or an image across pages:

# Text watermark
curl -X POST https://api.pdf-forge.dev/v1/pdf/watermark \
  -H "Authorization: Bearer $PDFFORGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"pdf\": \"$PDF\", \"text\": \"CONFIDENTIAL\", \"opacity\": 0.3}" \
  --output watermarked.pdf

# Image watermark (base64 PNG/JPG)
curl -X POST https://api.pdf-forge.dev/v1/pdf/watermark \
  -H "Authorization: Bearer $PDFFORGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"pdf\": \"$PDF\", \"image\": \"$(base64 -w0 logo.png)\", \"opacity\": 0.2}" \
  --output watermarked.pdf
FieldTypeDescription
pdfstringRequired. Base64 PDF.
textstringWatermark text (either text or image is required).
imagestringBase64 PNG/JPG watermark.
opacitynumber0..1.
colorstringText colour (text watermarks).
sizenumberFont size in points (text watermarks).
diagonalbooleanClassic diagonal stamp — default true.
positionstringPlacement when not diagonal.
rotationnumberCustom angle in degrees.
pagesstring[]Limit to pages/ranges, e.g. ["1", "3-5"].

To remove an overlay watermark, see True redactionstrip-watermark is documented there.

Page numbers

POST /v1/pdf/page-numbers — stamp page numbers:

curl -X POST https://api.pdf-forge.dev/v1/pdf/page-numbers \
  -H "Authorization: Bearer $PDFFORGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"pdf\": \"$PDF\", \"position\": \"bottom-center\"}" \
  --output numbered.pdf

Optional fields: format (number pattern), position, size (points), pages (selection).

Generation-time alternative

If you are generating the PDF yourself, watermark and password are also request fields on /v1/generate/html — one call instead of two.

Next steps

On this page