# PDF to Markdown & JSON Converter (Docling) (`actorzlab/docling-pdf-converter`) Actor

Convert PDF documents to clean Markdown, structured JSON, and plain text using IBM's open-source Docling AI. Handles text PDFs and scanned documents (OCR), extracts tables and images. No external API key required — runs fully on-device.

- **URL**: https://apify.com/actorzlab/docling-pdf-converter.md
- **Developed by:** [Khalil Drissi](https://apify.com/actorzlab) (community)
- **Categories:** Developer tools, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## PDF to Markdown & JSON Converter (Docling)

Convert PDF documents into clean **Markdown**, structured **JSON**, and plain **text** using IBM's open-source [Docling](https://github.com/DS4SD/docling) AI library. Handles regular text-based PDFs and scanned/image PDFs (with OCR), extracts tables with high accuracy, and optionally saves embedded images.

**No external API key required.** Docling runs entirely on-device inside the actor — nothing leaves the platform.

---

### Features

- **7 output formats in one run:** Markdown (great for RAG pipelines), structured JSON (full document hierarchy), and plain text
- **Table extraction:** Docling's TableFormer model detects and exports tables with accurate row/column structure — available as Markdown tables in the Markdown output and as structured arrays in JSON
- **Optional OCR:** Enable for scanned PDFs or image-based pages (using EasyOCR, Apache 2.0 licensed — no GPL dependencies)
- **Image extraction:** Save embedded images as PNG files to the key-value store
- **Batch processing:** Supply multiple URLs — each document is converted independently with per-item error isolation
- **Open protocol:** Official IBM Research library, MIT licensed, no ToS grey area

---

### Use cases

- **RAG / AI pipelines** — convert a library of PDFs to Markdown for ingestion into vector databases (LangChain, LlamaIndex, Haystack)
- **AI training data** — extract clean text and structured JSON from research papers, reports, and books
- **Document digitisation** — make scanned archives searchable with OCR
- **Data extraction** — extract structured tables from financial reports, scientific papers, legal documents
- **Content migration** — convert PDF documentation to Markdown for static-site generators or wikis

---

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `pdfUrls` | string[] | *(required)* | HTTP/HTTPS URLs to PDF files |
| `outputFormats` | string[] | `["markdown","json"]` | Which formats to produce: `markdown`, `json`, `text` |
| `enableOcr` | boolean | `false` | Run OCR on each page (needed for scanned PDFs) |
| `tableMode` | string | `"FAST"` | Table extraction: `FAST` or `ACCURATE` (complex tables) |
| `extractImages` | boolean | `false` | Save embedded images as PNG to the key-value store |
| `proxyConfiguration` | object | — | Optional proxy for PDF downloads |

#### Example inputs

**Basic — single PDF to Markdown + JSON:**
```json
{
  "pdfUrls": ["https://arxiv.org/pdf/1706.03762"],
  "outputFormats": ["markdown", "json"]
}
````

**Scanned PDF with OCR + accurate table extraction:**

```json
{
  "pdfUrls": ["https://example.com/scanned-report.pdf"],
  "outputFormats": ["markdown", "text"],
  "enableOcr": true,
  "tableMode": "ACCURATE"
}
```

**Batch with image extraction:**

```json
{
  "pdfUrls": [
    "https://example.com/report-q1.pdf",
    "https://example.com/report-q2.pdf"
  ],
  "outputFormats": ["markdown", "json"],
  "extractImages": true
}
```

***

### Output

#### Dataset record (one per document)

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "filename": "1706.03762.pdf",
  "status": "success",
  "pageCount": 15,
  "wordCount": 8241,
  "tableCount": 4,
  "imageCount": 0,
  "markdownKey": "1706_03762_a1b2c3d4.md",
  "jsonKey": "1706_03762_a1b2c3d4.json",
  "textKey": null,
  "markdownUrl": "https://api.apify.com/v2/key-value-stores/.../records/1706_03762_a1b2c3d4.md",
  "jsonUrl": "https://api.apify.com/v2/key-value-stores/.../records/1706_03762_a1b2c3d4.json",
  "textUrl": null,
  "errorMessage": null,
  "scrapedAt": "2026-05-24T12:00:00.000Z"
}
```

`status` values: `success`, `partial` (some pages failed), `error` (full failure; see `errorMessage`).

#### Key-value store

For each successfully converted document, the actor writes:

- `{stem}_{hash}.md` — Markdown with tables rendered as GFM tables
- `{stem}_{hash}.json` — Full Docling document JSON (hierarchy, bounding boxes, cell-level data)
- `{stem}_{hash}.txt` — Plain text (if `text` format selected)
- `{stem}_{hash}_img_N.png` — Embedded images (if `extractImages` is true)

***

### Pricing

Pay per event — you only pay for what you actually process.

| Event | Price | When charged |
|-------|-------|--------------|
| Page processed | **$0.005** | Per page converted (no OCR) |
| OCR page processed | **$0.020** | Per page converted with OCR |
| Table extracted | **$0.002** | Per table detected |
| Image extracted | **$0.001** | Per image saved |

**Example costs:**

- 100-page report, no OCR, 10 tables: **100 × $0.005 + 10 × $0.002 = $0.52**
- 50-page scanned report with OCR, 5 tables: **50 × $0.020 + 5 × $0.002 = $1.01**
- 1,000 research papers (avg 10 pages, 3 tables, no OCR): **~$58**

***

### Throughput & memory

- **Memory:** 4 GB minimum (PyTorch + layout models). Increase to 8 GB for large PDFs or `ACCURATE` table mode.
- **Speed (no OCR):** ~5–10 pages/min on a single CPU core.
- **Speed (OCR):** ~1–3 pages/min on a single CPU core.
- **Cold start:** ~10–30 seconds for model initialisation (models are pre-baked into the Docker image; no download at runtime).
- For large batches, use multiple actor runs in parallel — Apify handles scheduling automatically.

***

### Authentication

No authentication required. Docling accesses no external APIs — all processing is on-device.

The optional `proxyConfiguration` field is only used for **downloading PDFs** from URLs that may require a proxy (e.g., behind a corporate firewall). Conversion itself is always local.

***

### FAQ

**Q: Does it work on scanned PDFs?**
A: Yes — enable `enableOcr: true`. This runs EasyOCR (Apache 2.0) on each page. Expect ~1–3 pages/min and higher per-page cost.

**Q: How accurate is table extraction?**
A: Docling's TableFormer model is state-of-the-art for PDF table recognition. Use `tableMode: "ACCURATE"` for complex multi-column or merged-cell tables. Simple tables work well in `FAST` mode.

**Q: What's in the JSON output?**
A: The full Docling `DoclingDocument` serialised to JSON — includes document hierarchy (sections, paragraphs, tables, figures), bounding boxes, page references, and cell-level table data. Ideal for downstream parsing.

**Q: Can I process password-protected PDFs?**
A: No. Password-protected PDFs cannot be opened by Docling. Remove the password before uploading.

**Q: How does it compare to PDF.js or pdfplumber?**
A: Docling uses AI layout analysis and TableFormer for structural understanding — it correctly identifies headings, columns, captions, and complex tables in ways that regex/heuristic tools cannot. The tradeoff is higher memory and CPU cost.

***

### Legal

Docling is released under the **MIT License** by IBM Research. The OCR backend (EasyOCR) is **Apache 2.0**. No GPL-licensed components are included.

This actor downloads and processes PDFs you supply. You are responsible for ensuring you have the right to process the content of the PDFs under applicable copyright, data-protection (GDPR/CCPA), and terms-of-service law. Do not use this actor to process content you do not have permission to reproduce or analyse.

# Actor input Schema

## `pdfUrls` (type: `array`):

HTTP/HTTPS URLs of PDF files to convert. Each URL is downloaded and converted independently.

## `generateMarkdown` (type: `boolean`):

Export the document as Markdown (.md). Stored in the key-value store; URL appears in the dataset as markdownUrl.

## `generateJson` (type: `boolean`):

Export the full Docling document model as JSON (.json). Includes layout, tables, and reading-order structure. Stored in the key-value store; URL appears in the dataset as jsonUrl.

## `generateText` (type: `boolean`):

Export the document as plain text (.txt), with no markdown formatting. Stored in the key-value store; URL appears in the dataset as textUrl.

## `enableOcr` (type: `boolean`):

Run OCR on each page. Required for scanned or image-based PDFs where text is not extractable directly. Slower and costs more per page. Leave off for regular text-based PDFs.

## `tableMode` (type: `string`):

FAST: quick TableFormer pass (good quality, default). ACCURATE: higher-quality model pass (slower, better for complex tables).

## `extractImages` (type: `boolean`):

Save each embedded image found in the PDF as a PNG in the key-value store. Image URLs are not included in the Markdown/JSON output — retrieve them from the key-value store directly.

## `proxyConfiguration` (type: `object`):

Optional proxy for downloading PDFs. Docling itself runs locally so only the download step uses the proxy.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "generateMarkdown": true,
  "generateJson": true,
  "generateText": false,
  "enableOcr": false,
  "tableMode": "FAST",
  "extractImages": false
}
```

# Actor output Schema

## `convertedDocuments` (type: `string`):

No description

## `outputFiles` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "pdfUrls": [
        "https://arxiv.org/pdf/1706.03762"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("actorzlab/docling-pdf-converter").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "pdfUrls": ["https://arxiv.org/pdf/1706.03762"] }

# Run the Actor and wait for it to finish
run = client.actor("actorzlab/docling-pdf-converter").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762"
  ]
}' |
apify call actorzlab/docling-pdf-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=actorzlab/docling-pdf-converter",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "PDF to Markdown & JSON Converter (Docling)",
        "description": "Convert PDF documents to clean Markdown, structured JSON, and plain text using IBM's open-source Docling AI. Handles text PDFs and scanned documents (OCR), extracts tables and images. No external API key required — runs fully on-device.",
        "version": "0.0",
        "x-build-id": "8EGKnf8N80e1B97xo"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/actorzlab~docling-pdf-converter/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-actorzlab-docling-pdf-converter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/actorzlab~docling-pdf-converter/runs": {
            "post": {
                "operationId": "runs-sync-actorzlab-docling-pdf-converter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/actorzlab~docling-pdf-converter/run-sync": {
            "post": {
                "operationId": "run-sync-actorzlab-docling-pdf-converter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "pdfUrls"
                ],
                "properties": {
                    "pdfUrls": {
                        "title": "PDF URLs",
                        "type": "array",
                        "description": "HTTP/HTTPS URLs of PDF files to convert. Each URL is downloaded and converted independently.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "generateMarkdown": {
                        "title": "Generate Markdown",
                        "type": "boolean",
                        "description": "Export the document as Markdown (.md). Stored in the key-value store; URL appears in the dataset as markdownUrl.",
                        "default": true
                    },
                    "generateJson": {
                        "title": "Generate structured JSON",
                        "type": "boolean",
                        "description": "Export the full Docling document model as JSON (.json). Includes layout, tables, and reading-order structure. Stored in the key-value store; URL appears in the dataset as jsonUrl.",
                        "default": true
                    },
                    "generateText": {
                        "title": "Generate plain text",
                        "type": "boolean",
                        "description": "Export the document as plain text (.txt), with no markdown formatting. Stored in the key-value store; URL appears in the dataset as textUrl.",
                        "default": false
                    },
                    "enableOcr": {
                        "title": "Enable OCR",
                        "type": "boolean",
                        "description": "Run OCR on each page. Required for scanned or image-based PDFs where text is not extractable directly. Slower and costs more per page. Leave off for regular text-based PDFs.",
                        "default": false
                    },
                    "tableMode": {
                        "title": "Table extraction accuracy",
                        "enum": [
                            "FAST",
                            "ACCURATE"
                        ],
                        "type": "string",
                        "description": "FAST: quick TableFormer pass (good quality, default). ACCURATE: higher-quality model pass (slower, better for complex tables).",
                        "default": "FAST"
                    },
                    "extractImages": {
                        "title": "Extract embedded images",
                        "type": "boolean",
                        "description": "Save each embedded image found in the PDF as a PNG in the key-value store. Image URLs are not included in the Markdown/JSON output — retrieve them from the key-value store directly.",
                        "default": false
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Optional proxy for downloading PDFs. Docling itself runs locally so only the download step uses the proxy."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
