Documents (OCR)
Transform any document into AI-ready structured content with our powerful document processing API.
Transform any document into AI-ready structured content with our powerful document processing API.
The Documents API enables you to extract text, tables, and images from a wide variety of file formats including PDFs, Microsoft Office documents (Word, PowerPoint, Excel), images, and more. Using advanced OCR technology, even scanned documents and images with embedded text can be converted into clean, structured output formats like Markdown, HTML, or JSON. Perfect for building RAG pipelines, document digitization workflows, invoice processing, and any application that needs to understand document content.
Authentication
All requests require an API key passed as a Bearer token in the
Authorization header:
Authorization: Bearer YOUR_API_KEYSupported file formats
The Documents API accepts a wide range of document and image formats.
| Category | Extensions |
|---|---|
| Documents | .pdf, .docx, .pptx, .xlsx, .csv, .md, .asciidoc, .adoc, .html, .htm, .xhtml |
| Images | .png, .jpg, .jpeg, .tiff, .tif, .bmp, .webp |
| Special | .vtt, .xml, .json |
Output formats
Choose one or more output formats for your processed documents.
| Format | Description |
|---|---|
md | Markdown format (default) |
json | Structured JSON with DoclingDocument schema |
html | HTML format |
html_split_page | HTML split by page |
text | Plain text |
doctags | Document tags format |
Highlights
- Wide format support: process PDFs, Office documents, images, and more in a single API.
- Table extraction: fast or accurate modes for table structure detection.
- Multiple output formats: get results in Markdown, JSON, HTML, or plain text.
API endpoint
Process documents and images using multipart/form-data.
POST https://api.greenpt.ai/v1/tools/documents/convert/fileNote: This endpoint uses
multipart/form-datafor file uploads.
Basic example
A simple request to convert a PDF to markdown.
curl -X POST https://api.greenpt.ai/v1/tools/documents/convert/file \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "files=@document.pdf"import fs from 'node:fs';
const form = new FormData();
form.append(
'files',
new Blob([fs.readFileSync('document.pdf')]),
'document.pdf',
);
const response = await fetch(
'https://api.greenpt.ai/v1/tools/documents/convert/file',
{
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
body: form,
},
);
const result = await response.json();
console.log(result);import requests
url = "https://api.greenpt.ai/v1/tools/documents/convert/file"
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
with open("document.pdf", "rb") as f:
files = {"files": ("document.pdf", f)}
response = requests.post(url, headers=headers, files=files)
print(response.json())Advanced example
A more advanced request with OCR and table extraction options.
curl -X POST https://api.greenpt.ai/v1/tools/documents/convert/file \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "files=@document.pdf" \
-F "to_formats=md" \
-F "do_ocr=true" \
-F "table_mode=accurate" \
-F "do_table_structure=true" \
-F "include_images=true"import fs from 'node:fs';
const form = new FormData();
form.append(
'files',
new Blob([fs.readFileSync('document.pdf')]),
'document.pdf',
);
form.append('to_formats', 'md');
form.append('do_ocr', 'true');
form.append('table_mode', 'accurate');
form.append('do_table_structure', 'true');
form.append('include_images', 'true');
const response = await fetch(
'https://api.greenpt.ai/v1/tools/documents/convert/file',
{
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
body: form,
},
);
const result = await response.json();
console.log(result);import requests
url = "https://api.greenpt.ai/v1/tools/documents/convert/file"
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
data = {
"to_formats": "md",
"do_ocr": "true",
"table_mode": "accurate",
"do_table_structure": "true",
"include_images": "true"
}
with open("document.pdf", "rb") as f:
files = {"files": ("document.pdf", f)}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
files | binary[] | - | Required. Files to process. |
to_formats | string | "md" | Output format: "md", "json", "html", "html_split_page", "text", "doctags". |
do_ocr | string | "true" | Enable OCR processing for bitmap content. |
force_ocr | string | "false" | Replace existing text with OCR-generated text. |
do_table_structure | string | "true" | Extract table structure. |
table_mode | string | "accurate" | Table detection mode: "fast" or "accurate". |
include_images | string | "true" | Extract images from the document. |
Response format
{
"document": {
"filename": "document.pdf",
"md_content": "# Document Title\n\nExtracted content...",
"json_content": {
"schema_name": "DoclingDocument",
"version": "1.8.0",
"name": "document.pdf",
"origin": {
"mimetype": "application/pdf",
"filename": "document.pdf"
},
"body": { },
"texts": [ ],
"tables": [ ],
"pictures": [ ],
"pages": { }
},
"html_content": "<html>...</html>",
"text_content": "Plain text content..."
},
"status": "completed",
"errors": [],
"processing_time": 2.45,
"timings": {
"ocr": 1.2,
"parsing": 0.8,
"export": 0.45
}
}Use cases
- Document digitization: convert scanned documents and PDFs to searchable text.
- Data extraction: extract tables from financial reports and spreadsheets.
- Invoice processing: automate invoice and receipt data extraction.
- Academic research: process research papers with formulas and citations.
- Legacy migration: convert old document formats to modern standards.
- Accessibility: make image-based documents accessible with text extraction.
- Content indexing: prepare documents for search engine indexing.
- Translation prep: extract text for translation workflows.