Skip to content
ComPDF
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Add Watermark API

Add a text or image watermark to a PDF.

Feature

The ComPDF Self-hosted accepts files and a request JSON string through multipart/form-data, forwards the parameters to the private PDF SDK, and streams the result file back on success.

Synchronous Request

ItemValue
Authenticationx-api-key: your_api_key_here
Request URLPOST http://localhost:8080/api/v1/process/pdf/watermark/add
Content typemultipart/form-data
Success responseResult file stream

Request Parameters

ParameterTypeDescriptionRequired
fileFileSource PDF file.Yes
imageFileFileImage watermark file. Required only when request.type is image.No
requestStringJSON string containing the PDF SDK parameters below. If omitted, remaining non-file form-data fields are forwarded as the request object.No

Request Object Parameters

Put the following fields in the request JSON string.

ParameterTypePurpose
typeString or IntegerPDF to JSON content scope used by the ComPDF Web. 0 = text, 1 = table, 2 = all.
textStringWatermark text.
fontSizeNumberText watermark font size.
fontColorStringText color, for example #D32F2F.
opacityNumberWatermark opacity. Common range: 0 to 1.
rotationNumberWatermark rotation angle in degrees.
horizalignStringHorizontal alignment such as left, center, or right.
vertalignStringVertical alignment such as top, center, or bottom.
horizOffsetNumberHorizontal offset in points.
vertOffsetNumberVertical offset in points.
horizontalSpacingNumberHorizontal spacing for repeated watermarks.
verticalSpacingNumberVertical spacing for repeated watermarks.
fullScreenBooleanWhether to tile the watermark across the page.
pagesString or Number[]Pages to process. Examples: 1, 1,3-5, [1,3,4,5], or all when supported.
passwordStringSource PDF open password. Some routes remove it before forwarding when the SDK endpoint does not accept it directly.
outputFileNameStringOptional output filename. When present, it is used as the preferred download filename.

Request Example

bash
curl -X POST "http://localhost:8080/api/v1/process/pdf/watermark/add" \
  -H "x-api-key: your_api_key_here" \
  -F "[email protected]" \
  -F 'request={"type":"text","text":"ComPDF","fontSize":"","fontColor":"","opacity":0.3}'

Response

On success, the API returns the processed file stream with Content-Type and Content-Disposition headers. On failure, the ComPDF Self-hosted returns a normalized error JSON response.