# 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:** 14 total users, 1 monthly users, 96.7% runs succeeded, 0 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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).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": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,actorzlab/docling-pdf-converter"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/CzYHXY7kIOWHzHBwH/builds/8EGKnf8N80e1B97xo/openapi.json
