Add Watermark to Word - Image Watermark API
PDF4me Add Watermark to Word enables you to add customizable image watermarks to Word documents with comprehensive positioning and styling control. This API service processes Word files and adds image watermarks with precise scaling, transparency levels, positioning alignment, and advanced sizing options. The API receives Word document content and watermark image data through REST API calls, utilizing Base64 encoding for secure transmission. With support for professional image watermarking using PNG, JPG, JPEG, BMP, and GIF formats, this solution is ideal for document security, brand protection, and status indication 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: Professional image watermarks using PNG, JPG, JPEG, BMP, GIF formats
- Advanced Scaling: Precise scaling control with Scale parameter (0.1 to 10.0)
- Custom Dimensions: Override scaling with exact Width and Height in points
- Transparency Control: Semi-transparent option for subtle watermark effects
- Positioning Options: Center alignment or top-left positioning within margins
- Document-wide Application: Watermarks applied to all sections and headers
- Behind Text Placement: Watermarks positioned behind document content
- Culture Support: Locale-specific document metadata handling
REST API Endpoint
The PDF4me REST API uses standard HTTP methods to interact with resources. All watermark addition operations are performed through a single endpoint:
- Method: POST
- Endpoint:
office/ApiV2Word/AddWatermark
REST API Parameters
Complete list of parameters for the Add Watermark to Word 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
| Parameter | Type | Description | Example |
|---|---|---|---|
| document* | Object | Document reference. Must contain Name (string) — Word file name with .docx extension | { "Name": "document.docx" } |
| docContent* | Base64 | Word document content encoded in Base64 | UEsDBBQABgAIAAAA... |
| watermarkFileName* | String | Watermark image file name with extension (e.g., .png, .jpg) | watermark.png |
| watermarkFileContent* | Base64 | Watermark image file content encoded in Base64. Supports PNG, JPG, JPEG, BMP, GIF formats. Recommended: Use transparent PNG for best results | iVBORw0KGgoAAAANS... |
Optional Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| scale | Number (float) | Scaling factor for watermark image (0.1 to 10.0). 0.5 = 50% of original size, 1.0 = original size (default), 2.0 = 200% of original size. Overridden by Width/Height if provided | 1.5 |
| semiTransparent | Boolean | Transparency control. true = Watermark opacity set to 50%, false = Watermark opacity set to 100% (default). Creates subtle watermark effect when true | true |
| width | Number (double) | Watermark width in points (overrides Scale if provided). Must be positive value. If only Width provided, height calculated to maintain aspect ratio | 200 |
| height | Number (double) | Watermark height in points (overrides Scale if provided). Must be positive value. If only Height provided, width calculated to maintain aspect ratio | 150 |
| alignImage | Boolean | Positioning control. true = Center watermark on page (default), false = Align watermark to top-left within margins | true |
| cultureName | String | Culture code for document metadata (e.g., "en-US", "fr-FR", "de-DE"). Default: null (no culture-specific processing). Affects document language and formatting | en-US |
Watermark Sizing Priority
The watermark sizing follows this parameter priority:
- Width/Height - If provided, these exact dimensions are used
- Scale - If Width/Height not provided, Scale is applied to original image dimensions
- Original Image Size - If neither Width/Height nor Scale provided, original image size is used
Output
The PDF4me Add Watermark to Word REST API returns different responses based on the processing mode. The API returns the Word document as a Base64-encoded string in JSON format, not as binary data.
- Success Response
- Asynchronous Processing
- Error Responses
- Response Format Details
Synchronous Processing (Default)
The API processes the request and returns:
Status Code: 200 OK
Content-Type: application/json
Response Body:
{
"document": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC...",
"fileName": "document.docx",
"success": true,
"errorMessage": null
}
Response Fields:
- document (string): The Word document with watermark applied, encoded as Base64 string
- fileName (string): The output Word file name
- success (boolean): Indicates whether the request succeeded
- errorMessage (string or null): Error details when success is false
How to Use:
- Extract the
documentfield from the JSON response (Base64) - Decode the Base64 string to get the binary Word document data
- Save or process the Word file as needed
Example (JavaScript):
const response = await fetch(url, options);
const data = await response.json();
const wordBytes = atob(data.document); // Decode Base64
// Save or process wordBytes
Asynchronous Processing
Asynchronous behavior (202 Accepted with polling) is controlled by server configuration, not by a request body parameter. When enabled, the API may return a 202 status with a polling URL in the Location header. Poll the URL with GET requests until you receive 200 OK with the same response shape (document, fileName, success, errorMessage).
Error Responses
The API returns standard HTTP error codes with error details:
- Invalid request parameters
- Missing required fields (
documentwithName,docContent,watermarkFileName,watermarkFileContent) - Invalid Base64 encoding in
docContentorwatermarkFileContent - Invalid or corrupted Word document
- Invalid or corrupted watermark image
- Invalid parameter values (scale, width, height)
- Invalid or missing API key
- API key not properly Base64 encoded in Authorization header
- Missing
Authorization: Basicheader
- Server-side processing error
- Word document processing failure
- Watermark addition failure
Error Response Format:
{
"error": "Error message describing what went wrong"
}
Response Format Details
Important: The API always returns JSON, never binary Word data directly.
Response Structure:
{
"document": "string", // Base64-encoded Word document content
"fileName": "string", // Output Word filename
"success": true,
"errorMessage": "string or null"
}
Content-Type Header:
- Success:
application/json - The Word document is embedded as a Base64 string within the JSON response
Why Base64?
- JSON-safe encoding for binary data
- Easy to transmit over HTTP
- Compatible with all programming languages
- Can be directly embedded in JSON without escaping issues
Decoding Base64 to Word Document:
JavaScript/Node.js:
const base64 = response.document;
const binary = atob(base64); // Browser
// OR
const binary = Buffer.from(base64, 'base64'); // Node.js
Python:
import base64
word_bytes = base64.b64decode(response['document'])
with open('output.docx', 'wb') as f:
f.write(word_bytes)
C#:
byte[] wordBytes = Convert.FromBase64String(response.document);
File.WriteAllBytes("output.docx", wordBytes);
Request Example
Header
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 useAuthorization: Basic YWJjMTIz
Payload
Basic Example (Required Fields Only):
{
"document": { "Name": "document.docx" },
"docContent": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC...",
"watermarkFileName": "watermark.png",
"watermarkFileContent": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
}
Advanced Example (With All Optional Fields):
{
"document": { "Name": "document.docx" },
"docContent": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC...",
"watermarkFileName": "watermark.png",
"watermarkFileContent": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
"scale": 1.5,
"semiTransparent": true,
"width": 200,
"height": 150,
"alignImage": true,
"cultureName": "en-US"
}
Code Samples
The PDF4me Add Watermark to Word REST API provides code samples in multiple programming languages. Choose the language that best fits your development environment:
- C#
- Java
- JavaScript
- Python
- Salesforce
- n8n
- Google Script
- AWS Lambda
Google Script Sample
Google Apps Script implementation for Google Workspace integration:
Industry Use Cases & Applications
- Legal & Professional Services
- Business & Enterprise
- Education & Research
- Finance & Banking
Legal & Professional Services Use Cases
- Confidential Documents: Watermark legal documents with confidentiality notices
- Draft Contracts: Mark draft agreements with "DRAFT" status
- Privilege Labels: Apply attorney-client privilege watermarks
- Status Markers: Indicate document review or approval status
Business & Enterprise Use Cases
- Pricing Sheets: Add "Confidential Pricing" watermarks to rate cards
- Proposals: Watermark client proposals with copyright notices
- Internal Reports: Mark internal analytics with "Internal Use Only"
- Draft Materials: Indicate draft status on marketing materials
Education & Research Use Cases
- Patient Data: Add HIPAA compliance watermarks to patient records
- Medical and Research Data: Watermark lab results and research documents with confidentiality notices
- Institutional Documents: Apply institutional watermarks to academic and clinical materials
- Insurance and Compliance: Mark insurance and regulatory documents with privacy labels
Finance & Banking Use Cases
- Financial Statement Security: Add confidentiality watermarks to financial reports
- Draft Budgets: Watermark draft budget documents with "DRAFT" status
- Audit Documents: Apply audit firm watermarks to audit deliverables
- Client Reports: Add copyright watermarks to client-facing financial reports