Add Text Watermark to Word - Text Watermark API
PDF4me Add Text Watermark to Word enables you to add customizable text watermarks to Word documents with comprehensive styling and positioning control. This API service processes Word files and adds text watermarks with full control over text content, font family, font size, colors, rotation angles, orientation presets, and transparency levels. The API receives Word document content through REST API calls, utilizing Base64 encoding for secure transmission. With support for security labels, branding elements, confidentiality notices, and status markers, 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
- Text Watermark Support: Professional text watermarks with any custom text content
- Font Customization: Full control over font family, font name, and font size
- Color Options: Named colors, hex codes, RGB values, and 3-digit hex support
- Rotation Control: Custom rotation angles (0-360°) or predefined orientation presets
- Transparency Options: Semi-transparent or fully opaque watermark effects
- Automatic Sizing: Intelligent sizing based on text length and font size
- Document-wide Application: Watermarks applied to all sections and headers
- Behind Text Placement: Watermarks positioned behind document content
REST API Endpoint
The PDF4me REST API uses standard HTTP methods to interact with resources. All text watermark addition operations are performed through a single endpoint:
- Method: POST
- Endpoint:
office/ApiV2Word/AddTextWatermark
REST API Parameters
Complete list of parameters for the Add Text 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 descriptor. Must include Name (string): output Word file name with .docx extension | { "Name": "document.docx" } |
| docContent* | Base64 | Word document content encoded in Base64 | UEsDBBQABgAIAAAA... |
| watermarkText* | String | Text to display as watermark. Required - cannot be null, empty, or whitespace only. Examples: "CONFIDENTIAL", "DRAFT", "APPROVED" | CONFIDENTIAL |
Optional Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| fontFamily | String | Font family for watermark text. Common: "Arial", "Calibri", "Times New Roman", "Helvetica". Default: "Arial" | Arial |
| fontSize | Number (double) | Font size in points (1 to 1000). Default: 72 | 72 |
| fontColor | String | Text color. Named: "Red", "Blue", "Gray". Hex: "#FF0000", "FF0000". RGB: "RGB(255,0,0)". Default: "#808080" | #FF0000 |
| semiTransparent | Boolean | Transparency. true = opacity 50%, false = 100% (default) | true |
| rotation | Number (double) | Custom rotation angle (0-360°). Default: 0 | 45 |
| fontName | String | Font name for watermark text | Arial |
| orientation | String | Predefined orientation: Horizontal (0°), Vertical (90°), Diagonal (45°), Upside-Down (180°). Overrides rotation if provided | Diagonal |
| cultureName | String | Culture code (e.g., "en-US", "de-DE", "fr-FR"). Default: null | en-US |
Text Orientation Options
The watermark text orientation follows this parameter priority:
- orientation - If provided, uses predefined orientation angle
- rotation - If orientation not provided, uses custom rotation angle
- Default - If neither provided, uses 0° (horizontal)
Predefined Orientations:
- Horizontal: 0° (default)
- Vertical: 90°
- Diagonal: 45°
- Upside-Down: 180°
Output
The PDF4me Add Text Watermark to Word REST API returns a JSON response (ApiV2WordApiCallRes). On success the API returns the Word document as a Base64-encoded string in the document field, not as binary data.
- Success Response
- Error Responses
- Response Format Details
Success Response
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 text watermark applied, encoded as Base64
- fileName (string): The output Word file name
- success (boolean): Whether the operation succeeded
- errorMessage (string): Error message if success is false; otherwise null
How to Use:
- Check
success; if true, extract thedocumentfield from the JSON response - Decode the Base64 string to get the binary Word document data
- Save or process the Word file using
fileName
Example (JavaScript):
const response = await fetch(url, options);
const data = await response.json();
if (!data.success) throw new Error(data.errorMessage);
const wordBytes = atob(data.document);
// Save or process wordBytes
Error Responses
The API returns standard HTTP error codes with error details:
- Invalid request parameters
- Missing required fields (
document,docContent,watermarkText) watermarkTextcannot be null, empty, or whitespace only- Invalid Base64 encoding in
docContent - Invalid or corrupted Word document
- Invalid font size (must be between 1-1000)
- Invalid rotation angle
- 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
- Text 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 (ApiV2WordApiCallRes):
{
"document": "string", // Base64-encoded Word document content
"fileName": "string", // Output Word filename
"success": true,
"errorMessage": 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(response.fileName, 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...",
"watermarkText": "CONFIDENTIAL"
}
Advanced Example (With Optional Fields):
{
"document": { "Name": "document.docx" },
"docContent": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC...",
"watermarkText": "CONFIDENTIAL",
"orientation": "Diagonal",
"fontFamily": "Arial",
"fontSize": 72,
"fontColor": "#FF0000",
"semiTransparent": true,
"cultureName": "en-US"
}
Custom Rotation Example:
{
"document": { "Name": "document.docx" },
"docContent": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC...",
"watermarkText": "DRAFT",
"fontFamily": "Times New Roman",
"fontSize": 48,
"fontColor": "Gray",
"rotation": 45,
"semiTransparent": true
}
Code Samples
The PDF4me Add Text 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
C# (CSharp) Sample
Complete C# implementation for adding text watermarks to Word documents:
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 "CONFIDENTIAL" notices
- Draft Contracts: Mark draft agreements with "DRAFT - UNDER REVIEW" status
- Privilege Labels: Apply "ATTORNEY-CLIENT PRIVILEGE" text watermarks
- Status Markers: Indicate "APPROVED" or "PENDING REVIEW" status
Business & Enterprise Use Cases
- Pricing Sheets: Add "CONFIDENTIAL PRICING" text watermarks to rate cards
- Proposals: Watermark client proposals with "© 2024 [Company]" notices
- Internal Reports: Mark internal analytics with "INTERNAL USE ONLY"
- Draft Materials: Indicate "DRAFT - NOT FOR DISTRIBUTION" status
Education & Research Use Cases
- Patient Data: Add "HIPAA PROTECTED" text watermarks to patient records
- Medical Reports: Watermark lab results with "CONFIDENTIAL MEDICAL" notices
- Research Data: Apply "RESEARCH DATA - CONFIDENTIAL" text watermarks
- Insurance Claims: Mark insurance documents with "PRIVACY PROTECTED" labels
Finance & Banking Use Cases
- Financial Statement Security: Add "CONFIDENTIAL" text watermarks to financial reports
- Draft Budgets: Watermark draft budget documents with "DRAFT" status
- Audit Documents: Apply "AUDIT COPY" text watermarks to audit deliverables
- Client Reports: Add "© 2024 [Company]" text watermarks to client-facing reports