# PDF & Webpage to Markdown for AI / RAG (`wholesome_spring/pdf-webpage-to-markdown-for-ai-rag`) Actor

Convert web pages and PDF files to clean, LLM-ready Markdown. Strips nav, ads and footers, keeps headings, lists and tables. Optional RAG chunking, links, word counts. Pay only for successful URLs.

- **URL**: https://apify.com/wholesome_spring/pdf-webpage-to-markdown-for-ai-rag.md
- **Developed by:** [Czech Data Tools](https://apify.com/wholesome_spring) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.99 / 1,000 converted pages

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

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 examples already wired to this Actor's own input schema, see the [API](#api) section below.

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`).

# README

## PDF & Webpage to Markdown for AI / RAG

Turn any list of **web pages and PDF files** into **clean, LLM-ready Markdown** in one run. Paste URLs, get back Markdown with headings, lists and tables preserved, plus title, word count, token estimate, links and (optionally) ready-made **RAG chunks**.

No browser, no proxies, no setup – fast and cheap HTTP conversion that works on articles, docs, blogs, knowledge bases, reports, papers and other PDF documents.

### What it does

- 🌐 **HTML → Markdown** – removes navigation, headers, footers, sidebars, cookie bars, ads and share widgets, keeps the main content (headings, lists, tables, code blocks, links).
- 📄 **PDF → Markdown** – extracts the text layer, rebuilds paragraphs, detects headings by font size, fixes hyphenated line breaks and removes repeated page headers/footers and page numbers.
- ✂️ **Chunking for RAG** – optional heading-aware chunks of ~N tokens with overlap, each carrying its nearest heading. Drop straight into a vector DB (Pinecone, Qdrant, Weaviate, pgvector…).
- 🔗 **Links** – absolute URLs + anchor text from the main content.
- 🔒 **Privacy by default** – e-mail addresses and international phone numbers are redacted (can be turned off).
- 🤝 **Polite** – respects robots.txt, one request at a time per website with a pause between requests.
- 💸 **You only pay for successful conversions** – failed, blocked or empty URLs are not charged. They are listed in the key-value store record `FAILED_URLS`.

### Input

| Field | Description |
|---|---|
| `startUrls` | URLs of web pages and/or PDFs (type is detected automatically) |
| `extractMainContent` | Keep only the main content (default `true`) |
| `chunkSize` | Chunk size in tokens for RAG, `0` = off (default) |
| `chunkOverlap` | Overlap between chunks in tokens (default 50) |
| `includeLinks` | Add the list of links (default `true`) |
| `includeImages` | Keep image references in Markdown (default `false`) |
| `redactContactInfo` | Redact e-mails and phone numbers (default `true`) |
| `respectRobotsTxt` | Skip URLs disallowed by robots.txt (default `true`) |
| `maxPdfSizeMb`, `maxItems`, `maxConcurrency`, `requestDelayMs`, `timeoutSecs` | Limits and politeness settings |

Example:

```json
{
  "startUrls": [
    { "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation" },
    { "url": "https://arxiv.org/pdf/2005.11401" }
  ],
  "chunkSize": 500,
  "chunkOverlap": 50
}
```

### Output

One dataset item per successfully converted URL:

```json
{
  "url": "https://arxiv.org/pdf/2005.11401",
  "finalUrl": "https://arxiv.org/pdf/2005.11401",
  "status": 200,
  "contentType": "pdf",
  "title": "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks",
  "pageCount": 19,
  "wordCount": 10450,
  "tokenEstimate": 16200,
  "markdown": "# Retrieval-Augmented Generation ...",
  "links": [{ "url": "https://github.com/...", "text": null }],
  "linkCount": 12,
  "chunks": [{ "index": 0, "heading": "Abstract", "text": "...", "tokens": 498 }],
  "responseTimeMs": 1830,
  "fetchedAt": "2026-11-09T17:00:00.000Z"
}
```

Download as JSON, JSONL, CSV or Excel, or read it via the Apify API, Python/JS client, Make, Zapier, n8n or LangChain / LlamaIndex Apify loaders.

### Pricing

Pay per event: **$0.99 per 1,000 converted URLs** + a tiny $0.003 start fee per run. Failed URLs are free.

### Limitations

- Pages that render their content only with JavaScript (single-page apps) may return little text – the actor does not run a browser.
- Scanned PDFs without a text layer are skipped (no OCR).
- Pages behind a login or paywall are not supported.

### Use cases

- Feed websites and PDF documentation into a RAG chatbot or vector database
- Build LLM fine-tuning / evaluation corpora
- Convert reports, papers and manuals to Markdown for Obsidian/Notion
- Monitor content of pages for changes (combine with Apify schedules)

### Related Actors by Czech Data Tools

- [Sreality.cz Scraper & Price-Drop Monitor](https://apify.com/wholesome_spring/sreality-scraper-price-monitor) – Czech real estate
- [Bezrealitky.cz Scraper & Price-Drop Monitor](https://apify.com/wholesome_spring/bezrealitky-cz-scraper-price-drop-monitor)
- [Bazoš Scraper & New-Ad Monitor (CZ, SK, AT, PL)](https://apify.com/wholesome_spring/bazos-scraper-new-ad-monitor-cz-sk-at-pl)
- [Autobazar.eu Scraper & Price-Drop Monitor](https://apify.com/wholesome_spring/autobazar-eu-scraper-price-drop-monitor)
- [TopReality.sk Scraper & Price-Drop Monitor](https://apify.com/wholesome_spring/topreality-sk-scraper-price-drop-monitor)

Questions or feature requests? Open an issue on the Actor's Issues tab.

# Actor input Schema

## `startUrls` (type: `array`):

List of URLs to convert. HTML pages and PDF files are detected automatically (by Content-Type or %PDF header). You can also upload a text file with one URL per line.

## `extractMainContent` (type: `boolean`):

Strip navigation, headers, footers, sidebars, cookie bars, ads and share widgets and keep only the main article content. Turn off to convert the whole page body.

## `chunkSize` (type: `integer`):

If > 0, the Markdown is also split into chunks of roughly this many tokens (1 token ≈ 4 characters). Chunks respect headings and paragraphs and carry the nearest heading. Typical values: 256–1000.

## `chunkOverlap` (type: `integer`):

Approximate number of tokens repeated between consecutive chunks (whole paragraphs only). Ignored when chunking is off.

## `includeLinks` (type: `boolean`):

Add an array of absolute links (URL + anchor text) found in the main content.

## `includeImages` (type: `boolean`):

Keep ![alt](src) image references in the Markdown. Off by default because images are noise for most LLM/RAG use cases.

## `redactContactInfo` (type: `boolean`):

Replace e-mail addresses and international phone numbers in the output with placeholders, so you don't store personal contact data.

## `respectRobotsTxt` (type: `boolean`):

Skip URLs disallowed by the site's robots.txt. Only turn off for sites you own or have permission to crawl.

## `maxPdfSizeMb` (type: `integer`):

Larger files are skipped (and not charged).

## `maxItems` (type: `integer`):

Maximum number of URLs to process in one run.

## `maxConcurrency` (type: `integer`):

How many different hosts are processed in parallel. URLs on the same host are always fetched one by one.

## `requestDelayMs` (type: `integer`):

Polite pause between two requests to the same website (minimum 800 ms).

## `timeoutSecs` (type: `integer`):

How long to wait for one URL to download before giving up.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation"
    },
    {
      "url": "https://arxiv.org/pdf/2005.11401"
    }
  ],
  "extractMainContent": true,
  "chunkSize": 0,
  "chunkOverlap": 50,
  "includeLinks": true,
  "includeImages": false,
  "redactContactInfo": true,
  "respectRobotsTxt": true,
  "maxPdfSizeMb": 20,
  "maxItems": 1000,
  "maxConcurrency": 5,
  "requestDelayMs": 1000,
  "timeoutSecs": 30
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        {
            "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation"
        },
        {
            "url": "https://arxiv.org/pdf/2005.11401"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("wholesome_spring/pdf-webpage-to-markdown-for-ai-rag").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "startUrls": [
        { "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation" },
        { "url": "https://arxiv.org/pdf/2005.11401" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("wholesome_spring/pdf-webpage-to-markdown-for-ai-rag").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    {
      "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation"
    },
    {
      "url": "https://arxiv.org/pdf/2005.11401"
    }
  ]
}' |
apify call wholesome_spring/pdf-webpage-to-markdown-for-ai-rag --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,wholesome_spring/pdf-webpage-to-markdown-for-ai-rag"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/s7Qj7QdkxQ6ftLO0h/builds/u7JcLcUOtxa9U3cze/openapi.json
