# Convert PDFs to Markdown for RAG

**Use case:** 

Turns PDF links into clean Markdown and splits each document into chunks under its headings, with the heading path and page numbers on every chunk. Tables stay as Markdown tables and scanned pages are read with OCR. Feed the rows to a vector database or an LLM. Also reads Word, PowerPoint, Excel, HTML and EPUB.

## Input

```json
{
  "sources": [
    "https://nvlpubs.nist.gov/nistpubs/CSWP/NIST.CSWP.04162018.pdf"
  ],
  "outputFormat": "markdown",
  "ocr": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "maxPagesPerDocument": 5,
  "includeTables": true,
  "includeMetadata": true,
  "chunking": "by-headings",
  "chunkSize": 2000,
  "chunkOverlap": 200,
  "maxFileSizeMb": 50
}
```

## Output

```json
{
  "fileName": {
    "label": "File",
    "format": "string"
  },
  "fileType": {
    "label": "Type",
    "format": "string"
  },
  "title": {
    "label": "Title",
    "format": "string"
  },
  "pages": {
    "label": "Pages",
    "format": "integer"
  },
  "pagesOcr": {
    "label": "OCR pages",
    "format": "integer"
  },
  "wordCount": {
    "label": "Words",
    "format": "integer"
  },
  "language": {
    "label": "Language",
    "format": "string"
  },
  "tables": {
    "label": "Tables",
    "format": "integer"
  },
  "chunkIndex": {
    "label": "Chunk",
    "format": "integer"
  },
  "headingPath": {
    "label": "Heading path",
    "format": "array"
  },
  "warnings": {
    "label": "Warnings",
    "format": "array"
  },
  "url": {
    "label": "Source",
    "format": "string"
  },
  "status": {
    "label": "Status",
    "format": "string"
  }
}
```

## About this Actor

This example demonstrates how to use [PDF to Markdown & Document to Text for LLM/RAG, with OCR](https://apify.com/tinlark/document-to-markdown.md) with a specific input configuration. Visit the [Actor detail page](https://apify.com/tinlark/document-to-markdown.md) to learn more, explore other use cases, and run it yourself.


## How to integrate an Actor?

This Task's input is already configured above. Use it as-is rather than inventing a new one.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For full API examples (JavaScript, Python, CLI, MCP, OpenAPI), see this Task's Actor page: https://apify.com/tinlark/document-to-markdown.md

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).
