# Markdown to EPUB and PDF (`vizellie/markdown-to-epub-pdf`) Actor

Converts Markdown into a clean EPUB file and a print-ready PDF. Paste the text, give public file links, or point at a stored record. You get download links, a word count, a chapter count, a PDF page count, and a basic EPUB check.

- **URL**: https://apify.com/vizellie/markdown-to-epub-pdf.md
- **Developed by:** [Vi Zellie](https://apify.com/vizellie) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 documents

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

## Markdown to EPUB and PDF

Turn Markdown into a clean EPUB file and a print-ready PDF.

Paste the text, point at public file links, or name a record you already stored. Each one becomes its own document, with a download link, a word count, a chapter count and, for a PDF, a page count.

### Who it is for

Writers who draft in Markdown and want a file they can read on a phone or send to print. Also useful when a note, a newsletter or a short report should leave the editor as a book file.

### What you get

- One row per document, with the status `ok`, `partial` or `failed`.
- An EPUB file, a PDF file, or both. The row has a download link for each file that was saved.
- A word count and a chapter count.
- A page count for the PDF.
- A basic check of the EPUB. The row says whether that check passed.
- Headings, lists, nested lists, tables, code blocks, quotes, links, pictures and footnotes.
- Chapters split on heading 1 or heading 2, and a contents page you can turn off.
- Page sizes: A4, US Letter, 6 x 9 in and 5 x 8 in. You can set the margins and the body text size.
- A note on the row when a picture could not be fetched. The rest of the document is still saved.

Pictures are included only from public https links, and only when the file is a PNG or a JPEG. A picture that fails is left out. The link itself is not copied into the result row.

### Tutorial

1. Paste Markdown into **Markdown**, or add public https links under **Markdown file links**, or set **Stored Markdown key** to a record in this run's store. Use **Store name** if that record lives in a named store.
2. Set **Title**, **Author** and **Language** if you want them on the book. Author can be a pen name. Leave the title empty to use the first chapter heading.
3. Optionally add a **Cover image link**. It has to be a public https PNG or JPEG.
4. Leave **Table of contents** on, or turn it off. Choose **Chapter split**, **Page size**, **Margins** and **Base font size**.
5. Leave **Output formats** on both, or clear the one you do not want.
6. Leave **Max documents** at 5 unless you want a shorter run. The ceiling is 10.
7. Run the Actor. Open the Documents view for the counts and the download links. The files themselves are in the key-value store, under keys that start with `EPUB-` and `PDF-`. The `OUTPUT` record says how many rows were saved and how many were charged.

A document that fails is still saved as a row so you can see why. That row is not charged.

### Example input

```json
{
  "markdown": "# Notes from the coast\n\nThe first chapter starts here.\n\n## Tide\n\nA short section with a [link](https://example.com).\n",
  "markdownUrls": [],
  "markdownKey": "",
  "title": "Notes from the coast",
  "author": "A. Writer",
  "language": "en",
  "coverUrl": "",
  "tableOfContents": true,
  "chapterSplit": "h1",
  "pageSize": "6x9",
  "marginMm": 16,
  "fontSize": 11,
  "formats": ["epub", "pdf"],
  "maxDocuments": 5
}
```

### Example output

```json
{
  "status": "ok",
  "source": "text",
  "title": "Notes from the coast",
  "author": "A. Writer",
  "language": "en",
  "pageSize": "6x9",
  "formats": ["epub", "pdf"],
  "wordCount": 18,
  "chapterCount": 1,
  "pageCount": 2,
  "epubValid": true,
  "epubKey": "EPUB-1",
  "pdfKey": "PDF-1",
  "epubUrl": "https://api.apify.com/v2/key-value-stores/STORE/records/EPUB-1",
  "pdfUrl": "https://api.apify.com/v2/key-value-stores/STORE/records/PDF-1",
  "imagesSkipped": 0,
  "note": "",
  "retrievedAt": "2026-10-31T12:00:00.000Z"
}
```

The numbers above show the shape of a row. A real run fills them from your text. The download links use the store for that run.

### Pricing

You pay a small fee when the run starts, then a fee for each document that is converted and saved. Both files are part of that one fee. The dataset itself is not charged again.

| What | Price |
|---|---|
| Run start | $0.00005 |
| Document | $0.01 |

A failed document is saved with a status and is not charged. A partial document is saved and is not charged. Documents past **Max documents** are not read and are not charged.

**Examples**

- One document: $0.01, plus the $0.00005 start fee.
- Five documents: 5 x $0.01 = **$0.05**, plus the $0.00005 start fee.
- A run that only saves a failed row: **$0.00005**.

Use **Max documents** and the maximum cost per run to cap a single run. If this ever differs from the Pricing tab, the Pricing tab applies.

### Limits

- A document can be at most 250,000 characters, and a downloaded file at most 1.5 MB.
- At most 10 documents in a run, and at most 20 file links are looked at.
- File links have to be public https. Private addresses, localhost, and other schemes are blocked.
- A picture has to be a public https PNG or JPEG, at most 800 KB, and at most 30 pictures are fetched per document.
- HTML in the Markdown becomes plain text.
- If the run is close to its time limit, it stops and keeps the documents already saved.

### No personal data

This Actor does not collect personal data.

- It converts the text you provide. It does not browse a site, and it does not look up people.
- The book files contain the words you wrote.
- The dataset row has the title, the author name you set, counts and download links. It does not contain the document text.
- Logs do not contain the document text, the file links, or the addresses that were called.
- A picture that cannot be fetched is counted. The picture address is not stored on the row.

Do not put a private address or a secret in the text if you would not want it inside the book file.

### FAQ

**What if a picture link is broken?**
The picture is left out and the note says an image was skipped. The document is still saved and charged when the files were created.

**What if the text is huge or empty?**
An empty run saves one failed row and asks you to add text. A document over the size cap is a failed row. Neither is charged.

**Which page sizes can I use?**
A4, US Letter, 6 x 9 in and 5 x 8 in. Margins are in millimetres. The body size is in points.

**What does the EPUB check look for?**
That the file opens as an EPUB and includes a contents page. It is not a full certification.

### Next additions

- More of the same kind.
- Broader coverage.
- Small follow-ups later.

### Feedback

Missing a field? Open an issue on the Actor's Issues tab.

# Actor input Schema

## `markdown` (type: `string`):

The Markdown to convert. Headings, lists, tables, code, quotes, links, pictures and footnotes are kept. At most 250,000 characters. Longer text is saved as a failed row and is not charged.

## `markdownUrls` (type: `array`):

Public https links to Markdown files. Private and non-https links are blocked and are not charged. At most 20 links are read.

## `markdownKey` (type: `string`):

Key of a record that already holds the Markdown. Letters, digits, dots, underscores and hyphens only. Leave empty to skip.

## `markdownStore` (type: `string`):

Named key-value store for that record. Leave empty to use this run's default store. Only letters, digits and hyphens are kept.

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

Book title. Leave empty to use the first chapter heading, or Untitled.

## `author` (type: `string`):

Author or pen name. Leave empty to omit it.

## `language` (type: `string`):

Language tag, for example en or nl. A value that is not a language tag becomes en.

## `coverUrl` (type: `string`):

Optional public https link to a PNG or JPEG cover. Other pictures are skipped, and the book is still saved.

## `tableOfContents` (type: `boolean`):

Add a contents page to the PDF and to the EPUB reading order. A short contents list stays inside the EPUB either way.

## `chapterSplit` (type: `string`):

Start a new chapter at each heading of this level.

## `pageSize` (type: `string`):

PDF page size. The EPUB does not have a fixed page size.

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

Margin on each side of the PDF, in millimetres, from 8 to 40.

## `fontSize` (type: `integer`):

Body text size in the PDF, in points, from 8 to 18.

## `formats` (type: `array`):

Which files to save. Leave both on unless you only want one of them.

## `maxDocuments` (type: `integer`):

Most documents in one run, from 1 to 10. Default 5. Documents past the cap are not charged.

## Actor input object example

```json
{
  "markdown": "# A short note\n\nThis is one paragraph in a sample book.\n",
  "language": "en",
  "tableOfContents": true,
  "chapterSplit": "h1",
  "pageSize": "A4",
  "marginMm": 18,
  "fontSize": 11,
  "formats": [
    "epub",
    "pdf"
  ],
  "maxDocuments": 5
}
```

# Actor output Schema

## `documents` (type: `string`):

One row per document, with status, counts and download links.

## `documentDetails` (type: `string`):

The same rows, including the file keys and the page setup.

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

The OUTPUT record in the default key-value store.

## `epubFiles` (type: `string`):

One EPUB per converted document. Keys start with EPUB-.

## `pdfFiles` (type: `string`):

One PDF per converted document. Keys start with PDF-.

# 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 = {
    "markdown": `# A short note

This is one paragraph in a sample book.`,
    "language": "en",
    "chapterSplit": "h1",
    "pageSize": "A4",
    "formats": [
        "epub",
        "pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("vizellie/markdown-to-epub-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 = {
    "markdown": """# A short note

This is one paragraph in a sample book.
""",
    "language": "en",
    "chapterSplit": "h1",
    "pageSize": "A4",
    "formats": [
        "epub",
        "pdf",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("vizellie/markdown-to-epub-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 '{
  "markdown": "# A short note\\n\\nThis is one paragraph in a sample book.\\n",
  "language": "en",
  "chapterSplit": "h1",
  "pageSize": "A4",
  "formats": [
    "epub",
    "pdf"
  ]
}' |
apify call vizellie/markdown-to-epub-pdf --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,vizellie/markdown-to-epub-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/UpeJWsr48yCdoTwTI/builds/IMSUFqcBhRKe285nJ/openapi.json
