PDF OCR - Scanned Document to Text Converter
PDF4me Convert PDF to Editable PDF using OCR enables you to convert image-based PDF documents to fully editable PDFs using OCR technology. This API service processes scanned PDFs and image-based documents, extracting text and making documents searchable and editable. The API receives PDF content and OCR parameters through REST API calls, utilizing Base64 encoding for secure transmission. With support for quality control, intelligent OCR processing, and language specification, this solution is ideal for document digitization and content accessibility 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
- OCR Processing: Convert image-based PDFs to fully editable documents with text recognition
- Quality Control: Choose between Draft (1 API call per file) and High (2 API calls per page) quality processing
- Intelligent Processing: Skip OCR when text is already searchable to optimize performance
- Language Support: Specify document language for improved text recognition accuracy
- Base64 Encoding: Secure file content transmission using Base64 encoding
- Simple API Integration: RESTful API designed for automated PDF OCR workflows
REST API Endpoint
The PDF4me REST API uses standard HTTP methods to interact with resources. All OCR-based PDF conversion operations are performed through a single endpoint:
- Method: POST
- Endpoint:
/api/v2/ConvertOcrPdf
REST API Parameters
Complete list of parameters for the Convert PDF to editable PDF using OCR 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 |
|---|---|---|---|
| docContent* | Base64 | The content of the input PDF file encoded in Base64 format | JVBERi... |
| docName* | String | Source PDF file name with .pdf extension | output.pdf |
| qualityType* | String | OCR quality type: Draft (1 API call per file) for normal PDFs, High (2 API calls per page) for scanned documents | Draft |
| ocrWhenNeeded* | String | OCR only when needed: true to skip if text is already searchable, false to always perform OCR | true |
| outputFormat* | String | Output format (must be "true" for standard output) | true |
| isAsync* | Boolean | Enable asynchronous processing. When true, the API returns a 202 status and provides a polling URL in the Location header | true |
Optional Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| language | String | Language of text in source file (e.g., "English", "Spanish", "French", "German"). Only use if output is not recognizable | English |
| mergeAllSheets | Boolean | Merge all sheets if applicable | true |
Output
The PDF4me Convert PDF to Editable PDF using OCR REST API returns different responses based on the processing mode. The API returns the converted PDF as a Base64-encoded string in JSON format.
- Success Response
- Asynchronous Processing
- Error Responses
- Response Format Details
Synchronous Processing (Default)
When isAsync is 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 converted editable PDF, encoded as Base64 string
How to Use:
- Extract the
docContentfield from the JSON response - Decode the Base64 string to get the binary PDF data
- 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
Asynchronous Processing
When isAsync: true is set, the API processes the request asynchronously:
Status Code: 202 Accepted
Response Headers:
Location: https://api.pdf4me.com/api/v2/ConvertOcrPdf/poll/12345-abcde-67890
Polling Process:
- Extract the
Locationheader from the 202 response - Poll the URL using GET requests
- Continue polling until you receive a 200 OK status
- The final response contains the same JSON format with
docNameanddocContent(Base64)
Polling Example:
// Initial request returns 202 with Location header
const response = await fetch(url, options);
const location = response.headers.get('Location');
// Poll until complete
while (true) {
const pollResponse = await fetch(location, { headers: { 'Authorization': 'Basic ' + apiKey } });
if (pollResponse.status === 200) {
const data = await pollResponse.json();
// Process data.docContent (Base64 PDF)
break;
}
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds
}
Error Responses
| Status Code | Description | Example Response |
|---|---|---|
| 400 Bad Request | Invalid request parameters or missing required fields | {"error": "Missing required parameter: qualityType"} |
| 401 Unauthorized | Invalid or missing API key | {"error": "Unauthorized"} |
| 500 Internal Server Error | Server error during processing | {"error": "Internal server error"} |
Understanding the JSON Response
The OCR conversion response is a JSON object containing:
- docName: The output PDF file name
- docContent: The converted editable PDF, encoded as Base64 string
Base64 Decoding:
The docContent field contains the PDF file encoded in Base64. Decode it to get the binary PDF data:
const pdfBytes = atob(data.docContent); // JavaScript
import base64
pdf_bytes = base64.b64decode(data['docContent']) # Python
Request Example
Header
Content-Type: application/json
Authorization: Basic YOUR_BASE64_ENCODED_API_KEY
Note: The API key must be Base64 encoded. Get your API key from the PDF4me Dashboard
Payload
{
"docContent": "JVBERi...",
"docName": "output.pdf",
"qualityType": "Draft",
"ocrWhenNeeded": "true",
"language": "English",
"outputFormat": "true",
"isAsync": true
}
Code Samples
The PDF4me Convert PDF to editable PDF using OCR 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 converting PDF to editable PDF using OCR:
Google Script Sample
Google Apps Script implementation for Google Workspace integration:
OCR Conversion Features
Text Recognition Processing
- Advanced OCR Engine: Advanced optical character recognition for accurate text extraction
- Quality Options: Draft quality for normal PDFs, High quality for scanned documents
- Intelligent Detection: Automatic detection of searchable vs. image-based content
- Professional Results: High-quality text recognition with accurate character extraction
- Advanced Processing: Support for complex document layouts and formatting
Language Support
- Multi-language Recognition: Support for various languages and character sets
- Language Specification: Optional language parameter for improved accuracy
- Character Recognition: Accurate recognition of different alphabets and symbols
- Professional Processing: High-quality language-specific text recognition
- Flexible Input: Support for documents in multiple languages
Advanced Features
- Smart Processing: Intelligent OCR processing that skips unnecessary operations
- Format Flexibility: Support for various PDF formats and document types
- Professional Conversion: High-quality document conversion with clear text output
- Flexible Options: Customizable processing parameters for specific requirements
Industry Use Cases & Applications
- Legal & Professional Services
- Government & Compliance
- Education & Research
- Business & Enterprise
Legal & Professional Services Use Cases
- Legal Document Processing: Convert scanned legal documents to searchable, editable formats
- Legal Archive Processing: Digitize historical legal documents and archives
- Compliance Documentation: Convert regulatory documents to searchable formats for compliance monitoring
- Legal Document Accessibility: Make legal PDFs accessible for text search and editing
Government & Compliance Use Cases
- Archive Processing: Digitize historical documents and archives for digital preservation
- Compliance Documentation: Convert regulatory documents to searchable formats for compliance monitoring
- Public Records: Digitize public records and government documents
- Regulatory Documentation: Convert regulatory documents to editable formats
Education & Research Use Cases
- Academic Research: Digitize research papers and academic documents for text analysis
- Educational Content: Convert scanned educational documents to editable formats
- Research Archive Processing: Digitize historical research documents and archives
- Academic Document Accessibility: Make academic PDFs accessible for text search
Business & Enterprise Use Cases
- Document Digitization: Convert scanned paper documents to editable digital formats
- Business Process Automation: Automate document processing workflows with OCR conversion
- Content Management: Transform image-based content into editable, searchable documents
- Content Accessibility: Make image-based PDFs accessible for screen readers and text search