# URL and PDF to Markdown (`appreciative_duct/url-pdf-to-markdown`) Actor

Turn public web pages and PDF links into clean Markdown plus title, description, and word count. Built for LLM and RAG ingestion.

- **URL**: https://apify.com/appreciative_duct/url-pdf-to-markdown.md
- **Developed by:** [Ross AI](https://apify.com/appreciative_duct) (community)
- **Categories:** AI, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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

## URL and PDF to Markdown

This actor fetches public web pages and direct PDF links and returns clean Markdown for LLM or RAG ingestion. HTML goes through a reader view, then to Markdown. PDFs are read as text. Each row also has the final URL, source type, title, description, and word count.

A page that fails, or that has no extractable text, is one error row. The rest of the batch still finishes.

### Input

```json
{
  "urls": [
    "https://example.com",
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}
```

| Field | Default | What it does |
| --- | --- | --- |
| `urls` | required | 1 to 30 public http(s) pages or PDF links. Duplicates are dropped. |

Responses larger than 8 MB are skipped. Markdown is cut at 150,000 characters, and `truncated` is set when that happens.

### Output

```json
{
  "url": "https://example.com",
  "finalUrl": "https://example.com/",
  "sourceType": "html",
  "title": "Example Domain",
  "description": null,
  "markdown": "Example Domain\n\nThis domain is for use in illustrative examples.",
  "wordCount": 12,
  "truncated": false,
  "status": "ok",
  "error": null
}
```

`sourceType` is `html` or `pdf`. A file is treated as a PDF when the content type says so, the path ends in `.pdf`, or the body starts with `%PDF-`. The `SUMMARY` record counts HTML and PDF successes.

### Proxy and limits

The actor asks for the included datacenter proxy group `BUYPROXIES94952`. It does not use residential, Google SERP, or unblocker proxies. If that group is unavailable, it continues without a proxy. A page that answers 403 or 429, or times out, through the datacenter address is retried once with no proxy.

Localhost, link-local, and private addresses are refused. Each redirect is checked again before it is followed.

Pages that only render in a browser, and PDFs that are scans without a text layer, come back empty. This actor does not run a headless browser.

### Pricing

Pay-per-event code is in the actor and is not enabled. The event name is `page-converted` at $0.001 per page that produced Markdown, with no start fee. Error rows are not billed. Until monetization is turned on, runs are not charged for results. See `PRICING.md`.

# Actor input Schema

## `urls` (type: `array`):

Public web pages or direct PDF links, up to 30.

## Actor input object example

```json
{
  "urls": [
    "https://example.com",
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}
```

# Actor output Schema

## `pages` (type: `string`):

Markdown, title, description, word count, and source type.

## `summary` (type: `string`):

How many pages converted and which proxy was used.

# 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 = {
    "urls": [
        "https://example.com",
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("appreciative_duct/url-pdf-to-markdown").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 = { "urls": [
        "https://example.com",
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("appreciative_duct/url-pdf-to-markdown").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 '{
  "urls": [
    "https://example.com",
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}' |
apify call appreciative_duct/url-pdf-to-markdown --silent --output-dataset

```

## MCP server setup

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

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/TPVYhTyHswFdl4Vla/builds/4tXDR5N1tWQKd5M37/openapi.json
