PDF to Markdown API: Word, Excel, PPTX for RAG
Pricing
from $3.00 / 1,000 documents converted
PDF to Markdown API: Word, Excel, PPTX for RAG
PDF to markdown API for RAG and LLMs. Converts PDF, Word (DOCX), Excel, PowerPoint, CSV and web pages from public links into clean markdown with token counts and optional ready-to-embed chunks. Pay only for documents that convert.
Pricing
from $3.00 / 1,000 documents converted
Rating
0.0
(0)
Developer
Jackal Alpha
Maintained by CommunityActor stats
0
Bookmarked
1
Total users
0
Monthly active users
3 days ago
Last modified
Categories
Features
Share
By Jackal Alpha.
This PDF to markdown converter takes public links and returns clean markdown for LLM and RAG pipelines. It reads PDF, Word (.docx), Excel (.xlsx), PowerPoint (.pptx), CSV and web pages, so one Actor replaces a PDF tool plus a DOCX tool plus a spreadsheet tool. Each document becomes one dataset record with the markdown, detected type, title, page or sheet count, character count and approximate token count. Set a chunk size and the record also carries ready-to-embed chunks split at headings and paragraphs. Price: $0.003 per converted document ($3 per 1,000), and failed documents are free. Text only: no OCR, so a scanned PDF returns a clear, uncharged error.
OCR is optional. A scanned PDF with no text layer returns a clear SCANNED_PDF error, uncharged. Set ocr to true to read those pages with OCR (English or Arabic, slower, not exact).
What it does not do: no password-protected files, no old binary Office files (.doc, .xls, .ppt), no OCR of pictures inside Word files, and OCR does not rebuild tables.
Convert PDF, DOCX and XLSX to markdown: supported formats
| Format | How it is converted |
|---|---|
Text layer, page by page. Tables are found from the position of the text and written as markdown tables. Arabic and other right-to-left text is put back in reading order. Pages with no text layer are listed in warnings, or read with OCR when ocr is on. Blank lines are kept where the layout shows a paragraph gap. Title comes from the PDF's metadata. | |
| DOCX | Headings, nested lists, bold and italic, links and tables become markdown. Merged table cells are laid out on a plain grid. Each picture becomes a markdown image link with its alt text (imageMode). |
| XLSX | Every sheet becomes a markdown table under a ## heading with the sheet name. Dates are written as ISO dates. |
| CSV / TSV | One table. The delimiter (comma, semicolon, tab or pipe) is detected. |
| PPTX | Text of each slide under ## Slide N, in slide order. Speaker notes are not included. |
| HTML | The main article content is extracted (navigation, footers and scripts are dropped) and converted. If no article is found, the whole body is used. Scripts are never run. |
| Markdown, plain text | Passed through, with line endings tidied. |
The type is detected from the file content first, then the content type and file name. A .pdf link that serves HTML is converted as HTML.
Input: chunking documents for RAG
| Field | Type | Default | Meaning |
|---|---|---|---|
urls | list of strings | three small public documents | Public http(s) links. Repeats are skipped. |
recordKeys | list of strings | none | Keys of files you uploaded to a key-value store. |
keyValueStoreId | string | this run's default store | Store that holds those keys. |
maxPagesPerDocument | integer | 500 (max 5000) | Convert only the first N PDF pages or PPTX slides. 0 or empty uses 500. |
maxRowsPerSheet | integer | 1000 | Data rows kept per sheet or CSV, after the header. Max 100000; 0 also means 100000. |
maxFileSizeMb | integer | 25 | Larger files are rejected (1-50). |
chunkSize | integer | 0 (off) | Also return chunks of at most this many characters. |
chunkOverlap | integer | 0 | Characters repeated from the end of the previous chunk. Capped at half of chunkSize. |
includeMetadataOnly | boolean | false | Leave out markdown and chunks; keep type, title, counts and sizes. Converted documents are still charged. |
ocr | boolean | false | Read PDF pages that have no text layer with OCR. |
ocrLanguages | list | ["eng"] | eng and/or ara. For Arabic documents use ["ara"] alone: mixing languages lowers accuracy. |
ocrMaxPages | integer | 20 | Most pages OCR reads per document. |
imageMode | string | placeholder | Word pictures: placeholder (), inline (data URI) or drop. |
concurrency | integer | 4 | Documents converted in parallel (1-10). |
requestTimeoutSecs | integer | 60 | Download time limit per document (5-300). |
If neither urls nor recordKeys has an entry, the run fails.
Output
One record per document, always with the same fields:
{"url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf","recordKey": null,"finalUrl": "https://www.irs.gov/pub/irs-pdf/fw9.pdf","type": "pdf","title": "Form W-9 (Rev. March 2024)","pageCount": 6,"sheetCount": null,"sizeBytes": 140815,"characters": 37977,"approxTokens": 9495,"truncated": false,"markdown": "Form W-9\n(Rev. March 2024)\n\nRequest for Taxpayer\nIdentification Number and Certification\n...","chunks": [{ "index": 0, "heading": null, "characters": 1480, "approxTokens": 370, "text": "Form W-9 ..." }],"error": null}
approxTokensis characters divided by 4, rounded up. It is a rough guide for budgeting, not an exact count for any one model.pageCountis pages for PDF and slides for PPTX, otherwisenull.sheetCountis set for XLSX and CSV.truncatedistruewhenmaxPagesPerDocumentormaxRowsPerSheetcut the document short.chunksisnullunlesschunkSizeis above 0. Each chunk starts at a heading when it can, keeps a code block together when it fits, and stays withinchunkSizecharacters (overlap text is added on top, up tochunkOverlap).headingis the nearest heading above the chunk's start.- Failed documents have
errorset and everything elsenull. Examples:HTTP 404.,SCANNED_PDF: no text layer found, this looks like a scanned or image-only PDF. Set "ocr" to true to read it with OCR (slower).,Password-protected PDFs are not supported.
Use cases
- Prepare PDFs and Word files for a RAG pipeline or a vector database.
- Turn spreadsheets and slide decks into markdown tables and text for an LLM prompt.
- Estimate token counts for a document set before sending it to a model.
- Run the same conversion on a schedule or from your own code through the API.
How to run it from the API
Send links and get markdown back in one request. Replace YOUR_API_TOKEN with your Apify token.
$curl -X POST "https://api.apify.com/v2/acts/jackalalpha~docs-to-markdown/run-sync-get-dataset-items?token=YOUR_API_TOKEN" -H "Content-Type: application/json" -d '{"urls": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf"], "chunkSize": 1500, "chunkOverlap": 150}'
The response is a JSON array with one record per document, in the format shown under Output.
Pricing
Pay per event: $0.003 per successfully converted document (event document-converted), so 1,000 documents cost $3.00.
Worked example: you send 500 links. 470 convert, 25 return HTTP 404 and 5 are scanned PDFs. You pay for 470 documents: 470 x $0.003 = $1.41. The 30 error records are free.
Chunking and includeMetadataOnly do not change the price. If you set a maximum cost per run and it is reached, the run stops cleanly, delivers only documents that were paid for, and the status message says it stopped at the charge limit and how many documents were not processed.
Safety and limits
- Only
httpandhttpslinks are accepted. Links with embedded credentials are refused. - Links that point at private, loopback or link-local addresses (for example
localhost,10.x.x.x,192.168.x.x,169.254.169.254) are refused. The check runs on the resolved address at connection time, including every redirect, so a public name that redirects or resolves to an internal address is refused too. Up to 5 redirects are followed. - The size limit is enforced while downloading, on the decompressed data. Downloads time out after
requestTimeoutSecs. - Pages that need a login, cookies or JavaScript to show their content are not supported. You get whatever the plain server response contains.
- Memory: very large PDFs or spreadsheets (near the 50 MB ceiling) need more run memory. Lower the file size limit or the concurrency if a run runs out.
- PDF text comes in reading order as the file stores it. Tables are rebuilt from text positions: simple grids work well, tables with merged cells or text that wraps inside cells may split or merge columns. Figure labels can occasionally look like a table.
- OCR text can contain mistakes (Arabic more than English), loses layout and tables, and runs about 2 to 5 seconds per page. Language data is bundled, nothing is downloaded at run time.
Libraries and licences
| Purpose | Library | Licence |
|---|---|---|
| PDF text | unpdf (bundles Mozilla pdf.js) | MIT (pdf.js: Apache-2.0) |
| DOCX | mammoth | BSD-2-Clause |
| XLSX | read-excel-file | MIT |
| PPTX and DOCX metadata | jszip | MIT (dual-licensed MIT or GPL-3.0; used under MIT) |
| HTML parsing | jsdom | MIT |
| HTML main content | @mozilla/readability | Apache-2.0 |
| OCR | tesseract.js, @tesseract.js-data/eng, @tesseract.js-data/ara | Apache-2.0 |
| PDF page images for OCR | @napi-rs/canvas | MIT |
| HTML and DOCX to markdown | turndown, turndown-plugin-gfm | MIT |
| Actor runtime | apify | Apache-2.0 |
CSV parsing and PPTX text extraction are written in this Actor. No native binaries and no headless browser are used.
FAQ
How do I convert a PDF to markdown for an LLM? Put the PDF link in urls and read the markdown field of the record. Set chunkSize to also get chunks.
Which file types are supported? PDF, DOCX, XLSX, CSV and TSV, PPTX, HTML, Markdown and plain text. See the formats table.
How much does it cost? $0.003 per converted document, so 1,000 documents cost $3.00. Failed documents are free.
Why did my PDF fail with "SCANNED_PDF"? It is made of page images (a scan or photo). Set ocr to true to read it with OCR, or run your own OCR first. A failure here is free.
Can I convert files I do not have a public link for? Yes. Upload them to a key-value store and list the keys in recordKeys.
How do I get chunks for a vector database? Set chunkSize (for example 1500) and chunkOverlap (for example 150) and read the chunks array of each record.
Why is a spreadsheet cut off? Sheets are capped at maxRowsPerSheet data rows (1000 by default) so one huge file does not flood your pipeline. Raise it or set 0 for no cap.
Why are there fewer records than links? Repeated links are skipped. If you set a maximum cost per run and it ran out, the status message shows how many were not processed.
Does it keep my documents? It keeps nothing beyond the run's own dataset. Files are processed in memory.
Input limits. One run accepts up to 1000 urls and 1000 recordKeys per run, 500 pages per document by default (max 5000), 25 MB per file by default (max 50), 100000 rows per sheet at most. Above that the run stops at once with a clear message; split the work into several runs.