Skip to main content

Sign PDF - Digital Signature API

PDF4me Sign PDF enables you to add signature images to PDF documents with control over position, size, and appearance. This API service processes PDF files and adds signature images using Base64 encoding for secure transmission. The API receives PDF content and signature image data through REST API calls. This solution is ideal for document authentication, legal compliance, business workflows, and adding visual signatures to documents.

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 Signature Support: Add custom signature images to PDF documents with full control over positioning and sizing
  • Flexible Positioning: Control horizontal and vertical alignment with pixel-perfect accuracy
  • Custom Sizing: Adjust signature dimensions using both millimeter and pixel measurements
  • Advanced Formatting: Set opacity, margins, and background options for professional appearance
  • Page Targeting: Apply signatures to specific pages or entire documents
  • Print Control: Configure signatures to appear only in print or on screen
  • Professional Results: Create signatures that enhance document authentication and security
  • 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 PDF signing operations are performed through a single endpoint:

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

Supported PDF Signing Features

The API provides comprehensive support for various PDF signing capabilities:

Signature Image Support

  • Common Formats: Support for JPG, PNG, and other standard image formats
  • Base64 Encoding: Secure signature transmission through Base64 encoding
  • Flexible Sizing: Both millimeter (10-200mm) and pixel (20-600px) based sizing options
  • Quality Preservation: Maintains signature image quality in PDF output

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 (0-100mm) and pixel (0-300px) based measurements
  • Flexible Placement: Support for any page position with exact measurements
  • Page Targeting: Apply to specific pages or entire documents (optional)

Advanced Features

  • Opacity Control: Adjustable transparency (0-100) for subtle or prominent signatures
  • Background Mode: Option to place signatures behind or in front of content
  • Print Control: Configure signatures to appear in view and print or print only
  • Professional Appearance: High-quality signature rendering with clear visibility

REST API Parameters

Complete list of parameters for the Sign 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...
imageFile*Base64Signature image file content encoded in Base64iVBORw0KGgoAAAANSUhEUgAA...
imageName*StringSignature image file name with extension (e.g., .jpg, .png)signature.jpg
alignX*StringHorizontal alignment: Left, Center, or RightRight
alignY*StringVertical alignment: Top, Middle, or BottomBottom

Optional Parameters

ParameterTypeDescriptionExample
pagesStringPage options: "1", "1,3,5", "2-5", "1,3,7-10", "2-". If not specified, applies to all pages1-3
widthInMMStringSignature width in millimeters (10-200)50
heightInMMStringSignature height in millimeters (10-200)25
widthInPxStringSignature width in pixels (20-600)142
heightInPxStringSignature height in pixels (20-600)71
marginXInMMStringHorizontal margin in millimeters (0-100)20
marginYInMMStringVertical margin in millimeters (0-100)20
marginXInPxStringHorizontal margin in pixels (0-300)57
marginYInPxStringVertical margin in pixels (0-300)57
opacityStringOpacity (0-100): 0=invisible, 100=fully opaque100
showOnlyInPrintBooleanShow signature in view and print (true) or print only (false)true
isBackgroundBooleanPlace signature in background (true) or foreground (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 Sign 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 signature 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==",
"imageFile": "iVBORw0KGgoAAAANSUhEUgAA...",
"imageName": "signature.jpg",
"alignX": "Right",
"alignY": "Bottom"
}

Advanced Example (With All Optional Fields):

{
"docName": "output.pdf",
"docContent": "JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9LaWRzIFszIDAgUl0KL0NvdW50IDEKPD4KZW5kb2JqCjMgMCBvYmoKPDwKL1R5cGUgL1BhZ2UKL1BhcmVudCAyIDAgUgovTWVkaWFCb3ggWzAgMCA2MTIgNzkyXQovUmVzb3VyY2VzIDw8Ci9Gb250IDw8Ci9GMSA0IDAgUgo+Pgo+PgovQ29udGVudHMgNSAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwKL1R5cGUgL0ZvbnQKL1N1YnR5cGUgL1R5cGUxCi9CYXNlRm9udCAvSGVsdmV0aWNhCj4+CmVuZG9iago1IDAgb2JqCjw8Ci9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCi9GMSAxMiBUZgoxMDAgNzAwIFRkCihIZWxsbyBXb3JsZCkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagp4cmVmCjAgNgowMDAwMDAwMDAwIDY1NTM1IGYgCjAwMDAwMDAwMDkgMDAwMDAgbiAKMDAwMDAwMDA1NCAwMDAwMCBuIAowMDAwMDAwMTAxIDAwMDAwIG4gCjAwMDAwMDAxNzAgMDAwMDAgbiAKMDAwMDAwMDI0NCAwMDAwMCBuIAp0cmFpbGVyCjw8Ci9TaXplIDYKL1Jvb3QgMSAwIFIKPj4Kc3RhcnR4cmVmCjM0MQolJUVPRg==",
"imageFile": "iVBORw0KGgoAAAANSUhEUgAA...",
"imageName": "signature.jpg",
"pages": "1-3",
"alignX": "Right",
"alignY": "Bottom",
"widthInMM": "50",
"heightInMM": "25",
"widthInPx": "142",
"heightInPx": "71",
"marginXInMM": "20",
"marginYInMM": "20",
"marginXInPx": "57",
"marginYInPx": "57",
"opacity": "100",
"showOnlyInPrint": true,
"isBackground": false,
"async": true
}

Code Samples

The PDF4me Sign 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 signing PDF documents:

PDF Signing Features

Signature Image Control

  • Format Support: JPG, PNG, GIF, and other standard image formats
  • Quality Preservation: Maintains signature image quality and resolution in PDF output
  • Base64 Encoding: Secure signature transmission through Base64 encoding
  • Flexible Sizing: Both millimeter and pixel-based sizing options
  • Professional Appearance: High-quality signature rendering with clear visibility

Positioning and Layout

  • Alignment Control: Precise horizontal and vertical alignment options
  • Margin Settings: Both millimeter and pixel-based positioning
  • Flexible Placement: Support for any page position and orientation
  • Page Targeting: Apply to specific pages or entire documents
  • Size Control: Customizable dimensions for optimal placement

Advanced Features

  • Opacity Control: Adjustable transparency for subtle or prominent signatures
  • Background Mode: Option to place signatures behind or in front of content
  • Print Control: Configure signatures to appear only in print or on screen
  • Professional Results: Create signatures that enhance document authentication and security
  • Flexible Positioning: Control horizontal and vertical alignment with pixel-perfect accuracy

Industry Use Cases & Applications

Legal & Professional Services Use Cases

  • Legal Documentation: Apply signatures to legal contracts, agreements, and official documents
  • Contract Signing: Sign contracts and agreements digitally for legal validity
  • Court Documents: Apply digital signatures to court filings and legal documents
  • Compliance Requirements: Meet regulatory requirements for document signing and authentication

Get Help