Skip to main content

Add Image Stamp to PDF - Watermark API

PDF4me Add Image Stamp to PDF enables you to add customizable image stamps and watermarks to PDF documents. This API service processes PDF files and adds image watermarks with precise positioning, custom sizing, and formatting options for document branding and security. The API receives PDF content and image data through REST API calls, utilizing Base64 encoding for secure transmission. With support for flexible positioning, custom sizing, page targeting, and print control, this solution is ideal for document branding, copyright protection, and enterprise PDF workflows.

Authenticating Your API Request

To access the PDF4me REST API, every request must include proper authentication credentials. Authentication ensures secure communication and validates your identity as an authorized user of the REST API.

Key Features

  • Image Watermark Support: Add custom images as watermarks and stamps to PDF documents
  • Flexible Positioning: Control horizontal and vertical alignment with pixel-perfect accuracy
  • Custom Sizing: Adjust image dimensions using both millimeter and pixel measurements
  • Advanced Formatting: Set opacity, margins, and background options for professional appearance
  • Page Targeting: Apply stamps to specific pages or entire documents
  • Print Control: Configure stamps to appear only in print or on screen
  • Professional Results: Create image watermarks that enhance document security and branding
  • Seamless API Integration: RESTful API designed for automated PDF editing workflows and enterprise system integration

REST API Endpoint

The PDF4me REST API uses standard HTTP methods to interact with resources. All image stamp addition operations are performed through a single endpoint:

  • Method: POST
  • Endpoint: /api/v2/ImageStamp

Image Stamping Features

Image Format Support

  • Common Formats: Support for JPG, PNG, GIF, and other standard image formats
  • Base64 Encoding: Secure image transmission through Base64 encoding
  • Size Control: Both millimeter (10-200mm) and pixel-based (20-600px) sizing options

Positioning and Layout

  • Horizontal Alignment: Left, Center, or Right positioning options
  • Vertical Alignment: Top, Middle, or Bottom placement control
  • Margin Control: Precise positioning with both millimeter (0-100mm) and pixel-based (0-300px) measurements
  • Page Targeting: Apply to specific pages using page options (empty string for all pages, "1", "1,3,5", "2-5", "1,3,7-10", "2-")

Advanced Features

  • Opacity Control: Adjustable transparency (0-100): 0=invisible, 100=fully opaque
  • Background Mode: Option to place images behind (isBackground: true) or in front (isBackground: false) of content
  • Print Control: Configure stamps to appear only in print (showOnlyInPrint: true) or in view and print (showOnlyInPrint: false)
  • Asynchronous Processing: Support for async processing with polling for long-running operations

REST API Parameters

Complete list of parameters for the Add Image Stamp to PDF REST API. Parameters are organized by category for better understanding and implementation.

Important: Parameters marked with an asterisk (*) are required and must be provided for the API to function correctly.

Required Parameters

ParameterTypeDescriptionExample
docName*StringOutput PDF file name with .pdf extensionoutput.pdf
docContent*Base64The content of the input PDF file encoded in Base64JVBERi...
imageName*StringImage file name with extension (e.g., .png, .jpg)stamp.png
imageFile*Base64Image file content encoded in Base64 formatiVBORw0KGgoAAAANS...
alignX*StringHorizontal alignment: Left, Center, or RightCenter
alignY*StringVertical alignment: Top, Middle, or BottomMiddle

Optional Parameters

ParameterTypeDescriptionExample
pagesStringPage options: empty string for all pages, "1" for page 1, "1,3,5" for specific pages, "2-5" for page range, "1,3,7-10" for mixed, "2-" for pages from 2 to end"" or "1-3"
heightInMMStringImage height in millimeters (10-200)30
widthInMMStringImage width in millimeters (10-200)30
heightInPxStringImage height in pixels (20-600)85
widthInPxStringImage width in pixels (20-600)85
marginXInMMStringHorizontal margin in millimeters (0-100)10
marginYInMMStringVertical margin in millimeters (0-100)10
marginXInPxStringHorizontal margin in pixels (0-300)28
marginYInPxStringVertical margin in pixels (0-300)28
opacityIntegerOpacity level (0-100): 0=invisible, 100=fully opaque50
isBackgroundBooleanPlace stamp in background (true) or foreground (false)true
showOnlyInPrintBooleanShow only in print (true) or in view and print (false)false
asyncBooleanEnable asynchronous processing. When true, the API returns a 202 status and provides a polling URL in the Location headertrue

Output

The PDF4me Add Image Stamp to PDF REST API returns different responses based on the processing mode. The API returns the PDF as a Base64-encoded string in JSON format, not as binary data.

Synchronous Processing (Default)

When async is not set or set to false, the API processes the request immediately:

Status Code: 200 OK

Content-Type: application/json

Response Body:

{
"docName": "output.pdf",
"docContent": "JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9LaWRzIFszIDAgUl0KL0NvdW50IDEKPD4KZW5kb2JqCjMgMCBvYmoKPDwKL1R5cGUgL1BhZ2UKL1BhcmVudCAyIDAgUgovTWVkaWFCb3ggWzAgMCA2MTIgNzkyXQovUmVzb3VyY2VzIDw8Ci9Gb250IDw8Ci9GMSA0IDAgUgo+Pgo+PgovQ29udGVudHMgNSAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwKL1R5cGUgL0ZvbnQKL1N1YnR5cGUgL1R5cGUxCi9CYXNlRm9udCAvSGVsdmV0aWNhCj4+CmVuZG9iago1IDAgb2JqCjw8Ci9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCi9GMSAxMiBUZgoxMDAgNzAwIFRkCihIZWxsbyBXb3JsZCkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagp4cmVmCjAgNgowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMDkgMDAwMDAgbiAKMDAwMDAwMDA1NCAwMDAwMCBuIAowMDAwMDAwMTAxIDAwMDAwIG4gCjAwMDAwMDAxNzAgMDAwMDAgbiAKMDAwMDAwMDI0NCAwMDAwMCBuIAp0cmFpbGVyCjw8Ci9TaXplIDYKL1Jvb3QgMSAwIFIKPj4Kc3RhcnR4cmVmCjM0MQolJUVPRg=="
}

Response Fields:

  • docName (string): The output PDF file name
  • docContent (string): The PDF file with image stamp applied, encoded as Base64 string

How to Use:

  1. Extract the docContent field from the JSON response
  2. Decode the Base64 string to get the binary PDF data
  3. Save or process the PDF file as needed

Example (JavaScript):

const response = await fetch(url, options);
const data = await response.json();
const pdfBytes = atob(data.docContent); // Decode Base64
// Save or process pdfBytes

Request Example

Content-Type: application/json
Authorization: Basic YOUR_BASE64_ENCODED_API_KEY

Note:

  • Get your API key from the PDF4me Dashboard
  • The API key must be Base64 encoded and prefixed with "Basic " in the Authorization header
  • Example: If your API key is abc123, encode it to Base64 and use Authorization: Basic YWJjMTIz

Payload

Basic Example (Required Fields Only):

{
"docName": "output.pdf",
"docContent": "JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9LaWRzIFszIDAgUl0KL0NvdW50IDEKPD4KZW5kb2JqCjMgMCBvYmoKPDwKL1R5cGUgL1BhZ2UKL1BhcmVudCAyIDAgUgovTWVkaWFCb3ggWzAgMCA2MTIgNzkyXQovUmVzb3VyY2VzIDw8Ci9Gb250IDw8Ci9GMSA0IDAgUgo+Pgo+PgovQ29udGVudHMgNSAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwKL1R5cGUgL0ZvbnQKL1N1YnR5cGUgL1R5cGUxCi9CYXNlRm9udCAvSGVsdmV0aWNhCj4+CmVuZG9iago1IDAgb2JqCjw8Ci9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCi9GMSAxMiBUZgoxMDAgNzAwIFRkCihIZWxsbyBXb3JsZCkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagp4cmVmCjAgNgowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMDkgMDAwMDAgbiAKMDAwMDAwMDA1NCAwMDAwMCBuIAowMDAwMDAwMTAxIDAwMDAwIG4gCjAwMDAwMDAxNzAgMDAwMDAgbiAKMDAwMDAwMDI0NCAwMDAwMCBuIAp0cmFpbGVyCjw8Ci9TaXplIDYKL1Jvb3QgMSAwIFIKPj4Kc3RhcnR4cmVmCjM0MQolJUVPRg==",
"imageName": "stamp.png",
"imageFile": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
"alignX": "Center",
"alignY": "Middle"
}

Advanced Example (With All Optional Fields):

{
"docName": "output.pdf",
"docContent": "JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9LaWRzIFszIDAgUl0KL0NvdW50IDEKPD4KZW5kb2JqCjMgMCBvYmoKPDwKL1R5cGUgL1BhZ2UKL1BhcmVudCAyIDAgUgovTWVkaWFCb3ggWzAgMCA2MTIgNzkyXQovUmVzb3VyY2VzIDw8Ci9Gb250IDw8Ci9GMSA0IDAgUgo+Pgo+PgovQ29udGVudHMgNSAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwKL1R5cGUgL0ZvbnQKL1N1YnR5cGUgL1R5cGUxCi9CYXNlRm9udCAvSGVsdmV0aWNhCj4+CmVuZG9iago1IDAgb2JqCjw8Ci9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCi9GMSAxMiBUZgoxMDAgNzAwIFRkCihIZWxsbyBXb3JsZCkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagp4cmVmCjAgNgowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMDkgMDAwMDAgbiAKMDAwMDAwMDA1NCAwMDAwMCBuIAowMDAwMDAwMTAxIDAwMDAwIG4gCjAwMDAwMDAxNzAgMDAwMDAgbiAKMDAwMDAwMDI0NCAwMDAwMCBuIAp0cmFpbGVyCjw8Ci9TaXplIDYKL1Jvb3QgMSAwIFIKPj4Kc3RhcnR4cmVmCjM0MQolJUVPRg==",
"imageName": "stamp.png",
"imageFile": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
"alignX": "Center",
"alignY": "Middle",
"pages": "",
"heightInMM": "30",
"widthInMM": "30",
"heightInPx": "85",
"widthInPx": "85",
"marginXInMM": "10",
"marginYInMM": "10",
"marginXInPx": "28",
"marginYInPx": "28",
"opacity": 50,
"isBackground": true,
"showOnlyInPrint": false,
"async": true
}

Code Samples

The PDF4me Add Image Stamp to PDF REST API provides code samples in multiple programming languages. Choose the language that best fits your development environment:

C# (CSharp) Sample

Complete C# implementation for adding image stamps to PDF:

Industry Use Cases & Applications

Legal & Professional Services Use Cases

  • Legal Documentation: Apply legal disclaimers and confidentiality notices to legal documents
  • Contract Stamping: Add image stamps to contracts and agreements
  • Confidentiality Notices: Apply confidentiality image stamps to sensitive legal documents
  • Compliance Stamps: Add regulatory compliance image notices to legal documents

Get Help