# Split PDFs into RAG chunks for vector databases

**Use case:** 

Split PDF text into overlapping chunks with the pages each one came from, ready for embeddings in Pinecone, Weaviate, Chroma, Qdrant or any vector database. This example uses IRS Form W-9 with 1,000-character chunks and 150 characters of overlap.

## Input

```json
{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "output_format": "chunks",
  "include_markdown": true,
  "include_pages": false,
  "extract_tables": true,
  "chunk_size": 1000,
  "chunk_overlap": 150,
  "ocr_scanned_pages": false,
  "ocr_languages": [
    "eng"
  ],
  "ocr_max_pages_per_pdf": 2000,
  "export_images": false,
  "images_min_size_px": 64,
  "images_skip_duplicates": true,
  "images_format": "original",
  "images_max_per_pdf": 500,
  "page_images": false,
  "page_images_dpi": 150,
  "page_images_format": "png",
  "page_images_quality": 90,
  "page_images_thumbnail": false,
  "page_images_max_per_pdf": 2000,
  "remove_headers_footers": false,
  "remove_page_numbers": false,
  "remove_blank_lines": false,
  "skip_empty_pages": false,
  "max_pages_per_pdf": 2000,
  "max_pdf_size_mb": 100,
  "timeout_per_pdf_secs": 1800,
  "max_concurrency": 3
}
```

## Output

```json
{
  "source": {
    "label": "Source",
    "format": "text"
  },
  "status": {
    "label": "Status",
    "format": "text"
  },
  "page_count": {
    "label": "Pages",
    "format": "number"
  },
  "extracted_page_count": {
    "label": "Pages extracted",
    "format": "number"
  },
  "ocr_page_count": {
    "label": "OCR pages",
    "format": "number"
  },
  "title": {
    "label": "Title",
    "format": "text"
  },
  "author": {
    "label": "Author",
    "format": "text"
  },
  "char_count": {
    "label": "Characters",
    "format": "number"
  },
  "word_count": {
    "label": "Words",
    "format": "number"
  },
  "text": {
    "label": "Text",
    "format": "text"
  },
  "markdown": {
    "label": "Markdown",
    "format": "text"
  },
  "page": {
    "label": "Page",
    "format": "number"
  },
  "chunk_index": {
    "label": "Chunk",
    "format": "number"
  },
  "page_start": {
    "label": "From page",
    "format": "number"
  },
  "page_end": {
    "label": "To page",
    "format": "number"
  },
  "subject": {
    "label": "Subject",
    "format": "text"
  },
  "creator": {
    "label": "Creator",
    "format": "text"
  },
  "producer": {
    "label": "Producer",
    "format": "text"
  },
  "created_at": {
    "label": "Created at",
    "format": "text"
  },
  "modified_at": {
    "label": "Modified at",
    "format": "text"
  },
  "is_encrypted": {
    "label": "Protected",
    "format": "boolean"
  },
  "file_size_mb": {
    "label": "Size (MB)",
    "format": "number"
  },
  "source_type": {
    "label": "Source type",
    "format": "text"
  },
  "file_type": {
    "label": "File type",
    "format": "text"
  },
  "error_code": {
    "label": "Error code",
    "format": "text"
  },
  "error": {
    "label": "Note or error",
    "format": "text"
  },
  "processed_at": {
    "label": "Processed at",
    "format": "date"
  }
}
```

## How it works

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

The PDF Extractor All-in-One: Text, Tables & OCR Actor is ready to run with the inputs already set for "Split PDFs into RAG chunks for vector databases". [Sign up or log in](https://console.apify.com/create-task-from-example/Bl5nUQCYAKiQy9g9l) and you'll land in Apify Console with a copy of this exact task.

### 2. Start the "Split PDFs into RAG chunks for vector databases" task

The PDF Extractor All-in-One: Text, Tables & OCR Actor will start running based on the input automatically. You can also change all the input fields, like 📄 pdf urls, 🧾 output format, and more, to match your specific use case.

### 3. Receive the "Split PDFs into RAG chunks for vector databases" 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 source, status, pages, 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 "Split PDFs into RAG chunks for vector databases" task via API](https://apify.com/t800solutions/pdf-extractor.md).

## FAQ

### Which chunk size should I use?

500 to 1,500 characters with 10 to 20% overlap works for most embedding models. Each chunk keeps the pages it came from, for citations.

### Can I use it with LangChain or LlamaIndex?

Yes. Load the rows as documents with the Apify integrations for LangChain and LlamaIndex, or call the API from your code.

## About this Actor

This example demonstrates how to use [PDF Extractor All-in-One: Text, Tables & OCR](https://apify.com/t800solutions/pdf-extractor.md) with a specific input configuration. Visit the [Actor detail page](https://apify.com/t800solutions/pdf-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/t800solutions/pdf-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`).
