# Documentation Site to Single PDF (Offline Handbook) (`bossless/docs-to-pdf`) Actor

Crawl any documentation website and convert it into a single, beautifully formatted, bookmarked PDF handbook with cover page and table of contents. Built for Docusaurus, MkDocs, Sphinx, VitePress, and GitBook with clean print styling and pay-per-event pricing.

- **URL**: https://apify.com/bossless/docs-to-pdf.md
- **Developed by:** [Alexander Daskalov](https://apify.com/bossless) (community)
- **Categories:** Developer tools, Automation, AI
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 82.4% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 documentation page includeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Documentation Site to Single PDF (Offline Handbook)

Convert entire documentation websites into a single, beautifully formatted, publication-grade PDF handbook for offline reading, archiving, or feeding into LLMs.

Crawl documentation pages in their natural navigation sidebar hierarchy across **Docusaurus**, **MkDocs**, **Sphinx / ReadTheDocs**, **VitePress**, **GitBook**, **Mintlify**, **Nextra**, and **Starlight**. Each page is rendered with clean print styling (stripping headers, sidebars, search dialogs, and cookie popups) and assembled into a single unified PDF complete with nested bookmarks, an optional cover page, and a visual table of contents.

***

### Why Docs to PDF?

- ✈️ **Read Offline Anywhere:** Commuting, traveling, or on a flight without Wi-Fi? Load entire developer docs onto your tablet, laptop, or e-reader (reMarkable, Kindle Scribe, iPad).
- 📑 **Hierarchical Bookmarks & TOC:** Every chapter is indexed in the PDF outline. Internal headings (H2, H3) automatically nest beneath chapter titles.
- 🎨 **Distraction-Free Print Styling:** Removes sticky navigation bars, responsive sidebars, theme toggles, search modals, and cookie banners.
- 🤖 **LLM Context & RAG Ingestion:** Feed unified, cleanly formatted technical handbooks directly into Claude, ChatGPT, or local vector databases without noise.
- 💰 **Pay-Per-Event Pricing:** Pay only for pages successfully included in your handbook ($0.004–$0.005 per page). No flat monthly subscriptions or wasted compute fees.

***

### Supported Documentation Frameworks

Docs to PDF features automatic navigation detection tailored to the leading modern documentation engines:

| Engine | Sidebar & Navigation Order Detection | Chrome Stripping |
| :--- | :--- | :--- |
| **Docusaurus** (v2, v3) | `.theme-doc-sidebar-menu a.menu__link` | Navbar, sidebar, pagination, edit links hidden |
| **MkDocs / Material** | `.md-nav--primary a.md-nav__link` | Header, sidebar drawer, tabs, footer hidden |
| **Sphinx / ReadTheDocs** | `.wy-menu-vertical a`, `.sidebar-tree a` | Nav side, search box, version flyout hidden |
| **VitePress** | `#VPSidebarNav a`, `.VPSidebar a` | VPNav, VPSidebar, VPDocFooter hidden |
| **GitBook** | `[data-testid='table-of-contents'] a` | Header, sidebar, search overlay hidden |
| **Mintlify** | `#navigation-items a`, `#sidebar-content a` | Top navigation, sidebar, feedback prompt hidden |
| **Nextra** | `.nextra-sidebar a` | Header, sidebar, TOC hidden |
| **Starlight / Astro** | `#starlight__sidebar a` | Navigation sidebar and search button hidden |
| **Generic Documentation** | `<aside>`, `<nav>`, and sitemap.xml fallback | Universal print layout and page break rules |

***

### Key Features

- **Sequential Reading Order:** Discovers and renders pages in the exact order intended by the documentation author.
- **Sitemap XML Discovery:** Automatically locates `/sitemap.xml` to ensure zero orphan pages are missed.
- **Publication Cover Page:** Automatically formats an elegant dark-gradient cover page with your document title, subtitle, source URL, date, and page count.
- **Visual Table of Contents:** Generates a clean, printed TOC with chapter titles, dotted leaders, and exact page numbers.
- **Full PDF Bookmarks:** Uses native PDF bookmarks (`pypdf` outline) so you can jump between chapters with a click in any PDF reader.
- **Flexible Paper Formats:** Supports A4, Letter, Legal, A3, and A5 in portrait or landscape orientation with configurable millimetre margins.
- **Custom CSS Injection:** Add custom styles to hide specific corporate banners or tweak font families.

***

### Input Configuration

| Field | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `startUrls` | Array | `["https://mkdocs.org/"]` | Starting documentation URL or explicit list of URLs to crawl. |
| `maxPages` | Integer | `30` | Maximum number of pages to crawl and include in the final PDF (up to 2000). |
| `pathPrefix` | String | `""` | Restrict crawling to URLs starting with this prefix (e.g. `/docs` or `/en/latest/`). |
| `includeGlobs` | Array | `[]` | Only crawl URLs matching these patterns (e.g. `["*guide*", "*api*"]`). |
| `excludeGlobs` | Array | `[]` | Skip URLs matching these patterns (e.g. `["*changelog*", "*blog*"]`). |
| `crawlSitemap` | Boolean | `true` | Automatically inspect `/sitemap.xml` for complete URL coverage. |
| `paperFormat` | String | `"A4"` | Paper size: `"A4"`, `"LETTER"`, `"LEGAL"`, `"A3"`, or `"A5"`. |
| `landscape` | Boolean | `false` | Enable landscape layout for wide tables or code snippets. |
| `marginMm` | Integer | `15` | Page margin in millimetres. |
| `includeCover` | Boolean | `true` | Include publication cover page. |
| `includeToc` | Boolean | `true` | Include visual Table of Contents page. |
| `title` | String | `""` | Document title override (defaults to first page title). |
| `subtitle` | String | `"Offline Documentation Handbook"` | Subtitle shown on cover page. |
| `customCss` | String | `""` | Extra CSS injected before printing. |
| `waitMs` | Integer | `0` | Delay in milliseconds before capture (for dynamic JS rendering). |
| `outputFileName` | String | `""` | Custom filename for the PDF in the Key-Value Store. |

***

### Output

The actor saves the generated PDF directly into the run's default Key-Value Store and outputs a dataset record containing:

```json
{
  "status": "success",
  "pdfUrl": "https://api.apify.com/v2/key-value-stores/xyz123/records/mkdocs-documentation-handbook.pdf",
  "fileName": "mkdocs-documentation-handbook.pdf",
  "totalPages": 14,
  "pagesIncluded": 6,
  "pagesSkipped": 0,
  "fileSizeBytes": 1458920,
  "sourceUrl": "https://mkdocs.org/",
  "title": "MkDocs Documentation Handbook",
  "chapters": [
    {
      "title": "Overview",
      "url": "https://mkdocs.org/",
      "pages": 2
    },
    {
      "title": "Getting Started",
      "url": "https://mkdocs.org/getting-started/",
      "pages": 3
    }
  ],
  "stoppedReason": null,
  "createdAt": "2026-10-29T14:32:00.000Z"
}
```

***

### Pricing

Docs to PDF uses transparent **Pay-Per-Event (PPE)** pricing:

| Event | Tier | Price |
| :--- | :--- | :--- |
| **Actor start** | All users | $0.00005 |
| **Documentation page included** | Free & Bronze | **$0.0050** / page |
| | Silver | **$0.0045** / page |
| | Gold, Platinum, Diamond | **$0.0040** / page |

A complete 50-page documentation handbook costs just **$0.25**. If an individual page fails to render, you are not charged for it. You can set a budget limit using Apify's `maxTotalChargeUsd` to guarantee your run never exceeds your desired spend.

***

### Tips for Best Results

- **Path Prefix:** When converting a sub-section (like an API reference), set `pathPrefix` to `/api/` or `/v2/` so the crawler does not wander into the main marketing blog.
- **Dynamic Content:** If a documentation engine uses heavy client-side syntax highlighting or KaTeX math rendering, pass `waitMs: 500` to allow animations to settle.
- **Reading on E-Ink Readers:** For devices like the reMarkable or Kindle Scribe, standard A4 portrait format with 10–15mm margins provides the most comfortable font scale.

***

### Ready-Made Tasks

Get started immediately with these pre-configured tasks for common documentation conversions:

- [MkDocs to Single PDF: Offline Documentation Handbook](https://apify.com/bossless/docs-to-pdf/examples/mkdocs-to-single-pdf) — Crawl an MkDocs site in navigation order and compile into a single bookmarked PDF handbook.
- [Docusaurus to Single PDF: Complete Developer Guide](https://apify.com/bossless/docs-to-pdf/examples/docusaurus-to-single-pdf) — Convert Docusaurus sites into clean developer handbooks with cover page and table of contents.
- [API Documentation to Single PDF: Offline Reference](https://apify.com/bossless/docs-to-pdf/examples/api-docs-to-single-pdf) — Export technical API references into indexed, searchable single PDF documentation guides.

***

### Programmatic Usage

#### Python (`apify-client`)

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run_input = {
    "startUrls": [{"url": "https://www.mkdocs.org/"}],
    "maxPages": 10,
    "paperFormat": "A4",
    "includeCover": True,
    "includeToc": True,
    "title": "MkDocs Documentation Handbook"
}

run = client.actor("bossless/docs-to-pdf").call(run_input=run_input)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print("Download your PDF here:", item["pdfUrl"])
```

#### Node.js / TypeScript (`apify-client`)

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

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('bossless/docs-to-pdf').call({
    startUrls: [{ url: 'https://www.mkdocs.org/' }],
    maxPages: 10,
    includeCover: true,
    includeToc: true
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log('PDF URL:', items[0]?.pdfUrl);
```

#### cURL

```bash
curl -X POST "https://api.apify.com/v2/acts/bossless~docs-to-pdf/runs?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "startUrls": [{"url": "https://www.mkdocs.org/"}],
    "maxPages": 5
  }'
```

***

### Use with AI Agents (Apify MCP)

This Actor integrates seamlessly with the Apify Model Context Protocol (MCP) server for Claude, Cursor, and other agent platforms:

```
Tool: apify/docs-to-pdf
Arguments: {"startUrls": [{"url": "https://www.mkdocs.org/"}], "maxPages": 6, "title": "MkDocs Reference"}
```

***

### Frequently Asked Questions (FAQ)

#### Is this Actor affiliated with Docusaurus, MkDocs, GitBook, or Sphinx?

No. This Actor is an independent software utility developed by bossless. It is not affiliated with, sponsored by, or endorsed by Docusaurus (Meta), MkDocs, GitBook, Sphinx, VitePress, Mintlify, Nextra, or Starlight. It converts publicly accessible documentation web pages using standard browser rendering and PDF compilation.

#### How does the Actor discover documentation pages?

The Actor inspects the framework-specific navigation sidebar on the initial documentation page. Modern documentation engines structure their sidebars hierarchically, which allows the Actor to crawl pages in their logical reading order rather than random link order. If no sidebar is detected, it falls back to parsing `sitemap.xml` or discovery through internal page links within the same origin and path prefix.

#### What print styles are applied?

Standard web documentation contains sticky navigation headers, left sidebars, right "on this page" sidebars, search bars, and cookie consent banners that waste paper or look awkward in a document. Docs to PDF applies custom print CSS rules specifically tuned for major documentation engines to hide these interactive elements and maximize readable content space.

#### Are PDF bookmarks created?

Yes. The generated PDF handbook includes a multi-level PDF document outline (bookmarks) corresponding to each chapter and major headings within each chapter, making navigation instant in Adobe Acrobat, Apple Preview, and mobile PDF readers.

# Actor input Schema

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

Start URL of the documentation website or explicit list of documentation URLs to convert.

## `maxPages` (type: `integer`):

Maximum number of documentation pages to crawl and include in the final PDF. The run stops when this limit is reached or when all discovered documentation pages have been rendered.

## `pathPrefix` (type: `string`):

Restrict crawling to URLs starting with this path prefix (e.g. '/docs' or '/en/latest/'). Leave empty to automatically use the path of the start URL.

## `includeGlobs` (type: `array`):

Only include URLs matching any of these glob patterns (e.g. '*guide*', '*api*').

## `excludeGlobs` (type: `array`):

Skip URLs matching any of these glob patterns (e.g. '*changelog*', '*blog*').

## `crawlSitemap` (type: `boolean`):

Automatically check for and parse /sitemap.xml to discover all documentation pages in addition to sidebar links.

## `paperFormat` (type: `string`):

Page paper size for the PDF.

## `landscape` (type: `boolean`):

Render pages in landscape mode instead of portrait.

## `marginMm` (type: `integer`):

Margin around each documentation page in millimetres.

## `includeCover` (type: `boolean`):

Add a modern, beautifully designed publication cover page with title, subtitle, date, and page count.

## `includeToc` (type: `boolean`):

Add a visual Table of Contents page with chapter titles, page numbers, and dotted leaders.

## `title` (type: `string`):

Title shown on the cover page and PDF metadata. If omitted, the title of the first page or website is used.

## `subtitle` (type: `string`):

Subtitle displayed beneath the main title on the cover page.

## `customCss` (type: `string`):

Additional CSS injected into every page before printing (e.g. hide proprietary banners or custom elements).

## `waitMs` (type: `integer`):

Time in milliseconds to wait after page load before generating the PDF (useful for heavy client-side charts or syntax highlighters).

## `outputFileName` (type: `string`):

Name for the generated PDF file saved in the key-value store (e.g. 'mkdocs-handbook.pdf'). Defaults to a kebab-case slug of the title.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.mkdocs.org/"
    }
  ],
  "maxPages": 6,
  "crawlSitemap": true,
  "paperFormat": "A4",
  "landscape": false,
  "marginMm": 15,
  "includeCover": true,
  "includeToc": true,
  "title": "MkDocs Documentation Handbook",
  "subtitle": "Offline Documentation Handbook",
  "waitMs": 0
}
```

# Actor output Schema

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

No description

## `files` (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://www.mkdocs.org/"
        }
    ],
    "maxPages": 6,
    "title": "MkDocs Documentation Handbook"
};

// Run the Actor and wait for it to finish
const run = await client.actor("bossless/docs-to-pdf").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://www.mkdocs.org/" }],
    "maxPages": 6,
    "title": "MkDocs Documentation Handbook",
}

# Run the Actor and wait for it to finish
run = client.actor("bossless/docs-to-pdf").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://www.mkdocs.org/"
    }
  ],
  "maxPages": 6,
  "title": "MkDocs Documentation Handbook"
}' |
apify call bossless/docs-to-pdf --silent --output-dataset

```

## MCP server setup

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

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/d6htimagHniJ5sNNZ/builds/c6Dmg4Uj46BRvZneT/openapi.json
