# PDF to Markdown, one row per page for RAG

**Use case:** 

Turns PDF and Word files into Markdown for retrieval-augmented generation (RAG), one dataset row per PDF page with its page number, so each chunk can cite its page. PDF headings are guessed from a bigger font size; Word headings, lists and tables come from the document. Headers, footers and page numbers are removed. Run it as it is: the built-in 3-page sample PDF gives 3 rows, the Word sample 1.

## Input

```json
{
  "fileUrls": [],
  "splitBy": "page",
  "lineJoin": "smart",
  "removeHeadersFooters": true,
  "normalize": "basic",
  "outputFormat": "markdown",
  "ocr": "auto"
}
```

## Output

```json
{
  "status": {
    "label": "Status",
    "format": "string"
  },
  "fileName": {
    "label": "File name",
    "format": "string"
  },
  "linkNumber": {
    "label": "Link number",
    "format": "integer"
  },
  "format": {
    "label": "Format",
    "format": "string"
  },
  "part": {
    "label": "Part",
    "format": "integer"
  },
  "pageFrom": {
    "label": "From page",
    "format": "integer"
  },
  "pageTo": {
    "label": "To page",
    "format": "integer"
  },
  "pageCount": {
    "label": "Pages in file",
    "format": "integer"
  },
  "charCount": {
    "label": "Characters",
    "format": "integer"
  },
  "needsOcr": {
    "label": "Needs OCR",
    "format": "boolean"
  },
  "garbledSuspected": {
    "label": "Garbled text suspected",
    "format": "boolean"
  },
  "emptyPages": {
    "label": "Pages without text",
    "format": "integer"
  },
  "verticalTextPages": {
    "label": "Vertical text pages",
    "format": "integer"
  },
  "removedLines": {
    "label": "Removed lines",
    "format": "integer"
  },
  "textSource": {
    "label": "Text source",
    "format": "string"
  },
  "ocrPages": {
    "label": "OCR pages",
    "format": "integer"
  },
  "ocrPagesLeft": {
    "label": "Pages not OCR'd",
    "format": "integer"
  },
  "chargedEvents": {
    "label": "Charged events",
    "format": "integer"
  },
  "chargedOcrPages": {
    "label": "Charged OCR pages",
    "format": "integer"
  },
  "errorCode": {
    "label": "Error code",
    "format": "string"
  },
  "errorMessage": {
    "label": "Error message",
    "format": "string"
  },
  "ocrNote": {
    "label": "OCR note",
    "format": "string"
  },
  "text": {
    "label": "Text",
    "format": "string"
  }
}
```

## How it works

### 1. Sign up on Apify or log in

The PDF to Text & OCR - Scanned PDFs, Images, Word, Japanese Actor is ready to run with the inputs already set for "PDF to Markdown, one row per page for RAG". [Sign up or log in](https://console.apify.com/create-task-from-example/9WpjKuXNLYGcZLveh) and you'll land in Apify Console with a copy of this exact task.

### 2. Start the "PDF to Markdown, one row per page for RAG" task

The PDF to Text & OCR - Scanned PDFs, Images, Word, Japanese Actor will start running based on the input automatically. You can also change all the input fields, like file links, one row per, and more, to match your specific use case.

### 3. Receive the "PDF to Markdown, one row per page for RAG" output

Monitor the progress in real time. You will be notified as soon as your dataset is complete and ready for review. Each result includes data such as status, file name, link number, and more.

### 4. Integrate into your workflow

The final output is delivered in JSON, CSV, or Excel format, ready to be plugged into your workflow. You can also [run the "PDF to Markdown, one row per page for RAG" task via API](https://apify.com/quietworkslab/pdf-text-extractor.md).

## FAQ

### What does each row of the PDF to Markdown task contain?

Each row of the PDF to Markdown task holds one PDF page: the Markdown text, pageFrom and pageTo, the page count of the whole file, the character count and the file name. A Word file stays one row, because DOCX has no pages.

### How are headings and tables handled when converting PDF to Markdown?

The PDF to Markdown task guesses PDF headings from a bigger font size; Word headings, lists and tables come from the document. Tables in PDFs become lines with the cells separated by spaces, and complex layouts may come out in another order.

### How much does converting PDF to Markdown cost?

$0.003 per started 20 PDF pages with text or 50,000 DOCX characters; $0.004 per page read by AI OCR, plus the AI model billed to your account by apify/openrouter (no markup). Failed files, blank pages, garbled-looking text and samples are free.

## About this Actor

This example demonstrates how to use [PDF to Text & OCR - Scanned PDFs, Images, Word, Japanese](https://apify.com/quietworkslab/pdf-text-extractor.md) with a specific input configuration. Visit the [Actor detail page](https://apify.com/quietworkslab/pdf-text-extractor.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/quietworkslab/pdf-text-extractor.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`).
