PDF to Markdown & OCR for RAG (Arabic, French, English) avatar

PDF to Markdown & OCR for RAG (Arabic, French, English)

Pricing

from $3.00 / 1,000 text pages

Go to Apify Store
PDF to Markdown & OCR for RAG (Arabic, French, English)

PDF to Markdown & OCR for RAG (Arabic, French, English)

Convert PDFs, scans and images into clean Markdown and token-sized chunks for RAG and AI agents. Keeps headings and tables, reads Arabic right-to-left correctly, and OCRs scanned pages in Arabic, French and English.

Pricing

from $3.00 / 1,000 text pages

Rating

0.0

(0)

Developer

Kasbah Data

Kasbah Data

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

13 days ago

Last modified

Features

Limited permissions

Share

PDF to Markdown, PDF to text and OCR in one Actor. Turn PDFs, scans and images into clean Markdown and token-sized chunks you can drop straight into a RAG pipeline, a vector database or an AI agent. Built for documents that generic converters get wrong: Arabic text comes out in the right reading order, French and English stay intact, and scanned pages are read with OCR in all three languages.

What it does

  • Keeps document structure. Headings become #, ##, ###; bullet and numbered lists become Markdown lists; ruled tables become Markdown tables and are also returned as rows.
  • Reads Arabic correctly. Right-to-left lines are put back in logical order, numbers and Latin words inside Arabic sentences are not reversed, presentation-form glyphs are folded to normal letters, and Arabic tables keep their column order.
  • OCRs scanned pages automatically. In auto mode each page's text layer is checked; only pages that are scans (or have broken text) go through OCR, in Arabic, French and English.
  • Chunks for retrieval. Heading-aware chunks with a target token size and overlap. Chunks never end on a heading and never split a table row; big tables are split by rows with the header repeated. Each chunk carries its section path and page range, so answers can cite their source.
  • Cleans the noise. Running headers, footers and page numbers are removed; <!-- page N --> markers are kept for citations.

Input

{
"startUrls": [
{ "url": "https://example.com/annual-report-2024.pdf" },
{ "url": "https://example.com/scanned-contract.pdf" }
],
"ocrMode": "auto",
"ocrLanguages": "ara+fra+eng",
"outputMode": "document",
"chunkSizeTokens": 512,
"chunkOverlapTokens": 64
}

Link directly to the file, not to a viewer page. PDFs and images (PNG, JPEG, TIFF, WebP, multi-page TIFF) are supported.

Output

With outputMode: "document", one item per document:

{
"url": "https://example.com/annual-report-2024.pdf",
"fileName": "annual-report-2024.pdf",
"title": "Rapport annuel 2024",
"language": "fr",
"pageCount": 2,
"textPages": 2,
"ocrPages": 0,
"markdown": "<!-- page 1 -->\n\n# Rapport annuel 2024\n\nCe rapport présente…\n\n## 1. Résultats financiers\n\n| Indicateur | 2023 | 2024 | Variation |\n| --- | --- | --- | --- |\n| Chiffre d'affaires (M€) | 3,65 | 4,20 | +15 % |",
"chunks": [
{
"index": 1,
"text": "## 2. Priorités pour 2025\n\n- Lancer l'offre de traitement documentaire en arabe et en français.\n- …",
"tokens": 155,
"pageStart": 1,
"pageEnd": 2,
"headingPath": ["Rapport annuel 2024", "2. Priorités pour 2025"]
}
],
"tables": [{ "page": 1, "rows": [["Indicateur", "2023", "2024", "Variation"], ["Chiffre d'affaires (M€)", "3,65", "4,20", "+15 %"]] }],
"metadata": { "Title": "Rapport annuel 2024", "Producer": "LibreOffice 24.2" },
"truncated": false,
"warnings": []
}

With outputMode: "chunks", one item per chunk (text, tokens, pageStart, pageEnd, headingPath, plus the document's url, fileName, title and language), ready to embed and load into any vector database.

Documents that cannot be read produce an item with url and error and are not charged. A run summary with per-document page counts and warnings is saved as the OUTPUT record in the run's key-value store.

Use it from your code

Call it like a PDF-to-Markdown API from your own pipeline (LangChain, LlamaIndex, n8n, a cron job...):

Python (pip install apify-client)

from apify_client import ApifyClient
client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("kasbahdata/pdf-to-rag-markdown").call(run_input={
"startUrls": [
{
"url": "https://arxiv.org/pdf/1706.03762"
}
],
"outputMode": "chunks"
})
for item in client.dataset(run.default_dataset_id).iterate_items():
print(item)

JavaScript (npm install apify-client)

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: '<YOUR_APIFY_TOKEN>' });
const run = await client.actor('kasbahdata/pdf-to-rag-markdown').call({
"startUrls": [
{
"url": "https://arxiv.org/pdf/1706.03762"
}
],
"outputMode": "chunks"
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);

HTTP (one request, waits for the results)

curl -X POST "https://api.apify.com/v2/acts/kasbahdata~pdf-to-rag-markdown/run-sync-get-dataset-items?token=<YOUR_APIFY_TOKEN>" \
-H "Content-Type: application/json" \
-d '{"startUrls": [{"url": "https://arxiv.org/pdf/1706.03762"}], "outputMode": "chunks"}'

Your token is under Settings → API & Integrations in Apify Console. The Actor also works in Make, Zapier, n8n and from AI agents through the Apify MCP server.

Pricing

You pay per page processed, plus a tiny start fee per run:

EventPrice
Text page (read from the PDF text layer)$3 per 1,000 pages
OCR page (scanned page or image)$6 per 1,000 pages
Actor start (once per run)$0.0001 at the default 2 GB of memory ($0.00005 per GB)

There is no charge per result and no platform usage fee. Empty pages, pages that fail, and documents that cannot be downloaded are free. The run stops cleanly at your maximum charge per run, and pages beyond Max pages per document are never processed.

Use it from AI agents

The Actor works as a tool through the Apify MCP server: add it to your MCP client configuration and an agent can convert any document URL to Markdown on demand.

Good to know

  • Token counts are estimates (about 4 characters per token for Latin script, 2 for Arabic). They are close to common OpenAI-style tokenizers but not exact for any one model.
  • OCR pages keep headings and paragraphs, but table structure is not reconstructed from images yet.
  • Multi-column layouts (such as academic papers) are read line by line across the full page width in this version.
  • Password-protected PDFs cannot be opened.
  • OCR quality depends on the scan. Pages below 60% OCR confidence are flagged in warnings; try ocrDpi: 400 for small print.

Feedback

Found a document it gets wrong, or need a field it doesn't return? Open an issue on the Issues tab and I'll look at it. If the Actor saved you time, a short review on the Actor page helps other people find it.