Skip to main content

Add Text Stamp to PDF - Text Watermark API

PDF4me Add Text Stamp to PDF enables you to add customizable text watermarks to PDF documents for authorization and piracy prevention. This API service processes PDF files and adds text stamps with control over text, position, styling, rotation, and appearance. The API receives PDF content through REST API calls, utilizing Base64 encoding for secure transmission. This solution is ideal for document branding, copyright protection, status indicators, 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

  • Flexible Positioning: Control horizontal and vertical alignment with pixel-perfect accuracy
  • Custom Styling: Choose from various fonts, sizes, colors, and text effects (bold, italic, underline)
  • Advanced Formatting: Set opacity, rotation, margins, and background options
  • 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 watermarks that enhance document security and branding
  • Asynchronous Processing: Support for async processing with polling for long-running operations

REST API Endpoint

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

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

Supported Text Stamping Features

The API provides comprehensive support for various text stamping and watermarking capabilities:

Text Customization Options

  • Font Selection: Choose from Arial, Times New Roman, Helvetica, or Courier New
  • Size Control: Adjustable font size from 8 to 72
  • Color Options: Full color spectrum support with hex color codes (e.g., #FF0000 for red)
  • Text Effects: Bold, italic, and underline formatting options
  • Custom Text: Support for any text content including symbols and special characters

Positioning and Layout

  • Horizontal Alignment: Left, center, and right positioning options
  • Vertical Alignment: Top, middle, and bottom placement control
  • Margin Control: Precise positioning with both millimeter and pixel-based measurements
  • Rotation Support: Text rotation: 0 (horizontal), 45 (diagonal), 90 (vertical), -45 (reverse diagonal)
  • Flexible Placement: Support for any page position with exact measurements

Advanced Features

  • Opacity Control: Adjustable transparency (0-100) for subtle or prominent watermarks
  • Background Mode: Option to place text behind or in front of content
  • Print Control: Configure stamps to appear in view and print or print only
  • Page Targeting: Apply to specific pages or entire documents
  • Text Fitting: Automatic text sizing to fit page boundaries (optional)

REST API Parameters

Complete list of parameters for the Add Text 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*Base64PDF file content encoded in Base64JVBERi...
pages*StringPage options: "all", "1", "1,3,5", "2-5", "1,3,7-10", "2-"all
text*StringText to be stamped as watermarkCONFIDENTIAL - PDF4me Watermark
alignX*StringHorizontal alignment: left, center, or rightcenter
alignY*StringVertical alignment: top, middle, or bottommiddle

Optional Parameters

ParameterTypeDescriptionExample
marginXInMMStringHorizontal margin from left edge in millimeters50
marginYInMMStringVertical margin from top edge in millimeters50
marginXInPxStringHorizontal margin from left edge in pixels150
marginYInPxStringVertical margin from top edge in pixels150
opacityStringOpacity (0-100): 0=invisible, 100=fully opaque30
fontNameStringFont name: Arial, Times New Roman, Helvetica, Courier NewArial
fontSizeIntegerFont size (8-72)24
fontColorStringFont color in hex format (e.g., #FF0000 for red)#FF0000
isBoldBooleanMake text bold (true) or regular (false)true
isItalicsBooleanMake text italic (true) or normal (false)false
underlineBooleanUnderline the text (true) or not (false)false
rotateIntegerRotation angle: 0 (horizontal), 45 (diagonal), 90 (vertical), -45 (reverse diagonal)45
isBackgroundBooleanPlace stamp in background (true) or foreground (false)true
showOnlyInPrintBooleanShow stamp in view and print (false) or print only (true)false
transverseBooleanTransverse positioning (true) or normal (false)false
fitTextOverPageBooleanFit text over entire page (true) or use specified size (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 Text 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 text stamp added, 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==",
"pages": "all",
"text": "CONFIDENTIAL - PDF4me Watermark",
"alignX": "center",
"alignY": "middle"
}

Advanced Example (With All Optional Fields):

{
"docName": "output.pdf",
"docContent": "JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9LaWRzIFszIDAgUl0KL0NvdW50IDEKPD4KZW5kb2JqCjMgMCBvYmoKPDwKL1R5cGUgL1BhZ2UKL1BhcmVudCAyIDAgUgovTWVkaWFCb3ggWzAgMCA2MTIgNzkyXQovUmVzb3VyY2VzIDw8Ci9Gb250IDw8Ci9GMSA0IDAgUgo+Pgo+PgovQ29udGVudHMgNSAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwKL1R5cGUgL0ZvbnQKL1N1YnR5cGUgL1R5cGUxCi9CYXNlRm9udCAvSGVsdmV0aWNhCj4+CmVuZG9iago1IDAgb2JqCjw8Ci9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCi9GMSAxMiBUZgoxMDAgNzAwIFRkCihIZWxsbyBXb3JsZCkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagp4cmVmCjAgNgowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMDkgMDAwMDAgbiAKMDAwMDAwMDA1NCAwMDAwMCBuIAowMDAwMDAwMTAxIDAwMDAwIG4gCjAwMDAwMDAxNzAgMDAwMDAgbiAKMDAwMDAwMDI0NCAwMDAwMCBuIAp0cmFpbGVyCjw8Ci9TaXplIDYKL1Jvb3QgMSAwIFIKPj4Kc3RhcnR4cmVmCjM0MQolJUVPRg==",
"pages": "all",
"text": "CONFIDENTIAL - PDF4me Watermark",
"alignX": "center",
"alignY": "middle",
"marginXInMM": "50",
"marginYInMM": "50",
"marginXInPx": "150",
"marginYInPx": "150",
"opacity": "30",
"fontName": "Arial",
"fontSize": 24,
"fontColor": "#FF0000",
"isBold": true,
"isItalics": false,
"underline": false,
"rotate": 45,
"isBackground": true,
"showOnlyInPrint": false,
"transverse": false,
"fitTextOverPage": false,
"async": true
}

Code Samples

The PDF4me Add Text 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 text stamps to PDF:

Text Stamping Features

Customization Options

  • Font Control: Multiple font families with size and color customization
  • Text Effects: Bold, italic, and underline formatting options
  • Color Management: Full spectrum color support with hex codes
  • Text Content: Support for any text including symbols and special characters
  • Professional Styling: High-quality text rendering with clear visibility

Positioning and Layout

  • Alignment Control: Precise horizontal and vertical alignment options
  • Margin Settings: Both millimeter and pixel-based positioning
  • Rotation Support: Text rotation for diagonal or angled watermarks
  • Flexible Placement: Support for any page position and orientation
  • Page Targeting: Apply to specific pages or entire documents

Advanced Features

  • Opacity Control: Adjustable transparency for subtle or prominent watermarks
  • Background Mode: Option to place text behind or in front of content
  • Print Control: Configure stamps to appear only in print or on screen
  • Text Fitting: Automatic text sizing to fit page boundaries
  • Transverse Mode: Apply stamps across the entire page

Industry Use Cases & Applications

Legal & Professional Services Use Cases

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

Get Help