# Markdown to PDF API

> Markdown to PDF is a PDF generator API that converts markdown text into professionally formatted PDF documents, with a clean default stylesheet (sans-serif text, bordered tables, shaded code blocks), and returns a temporary download URL for each file. Paid plans can set the paper size, orientation and margins, style the document with their own CSS, and print a header and footer with page numbers on every page.

**Endpoint:** `POST https://api.apiverve.com/v1/markdowntopdf`  
**Category:** Data Conversion  
**Cost:** 30 credits per call  
**Canonical page:** https://apiverve.com/marketplace/markdowntopdf

## Overview

Supports standard markdown formatting including headers, lists, links, and emphasis with automatic HTML rendering before PDF conversion. The free plan renders on A4 portrait with 0.4 inch margins and the browser's default styling. On paid plans, format picks A4, Letter, Legal, Tabloid, Ledger, A3, A5 or A6, landscape turns the page, the four margin parameters set each edge in inches, css styles the rendered markdown, and headerTemplate and footerTemplate print on every page with page number, page count, date and title placeholders.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/markdowntopdf" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"markdown":"# Sample Document\n\n## Introduction\n\nThis is a sample markdown document that will be converted to PDF.\n\n### Key Points\n\n- **First point**: This is important\n- **Second point**: This is also important\n- *Third point*: Don'\''t forget this\n\n## Conclusion\n\nThank you for using our API!","format":"value","landscape":true,"marginTop":1,"marginRight":1,"marginBottom":1,"marginLeft":1,"css":"value","headerTemplate":"value","footerTemplate":"value"}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `markdown` | string | Yes | Markdown text to convert (max 500,000 characters). length 0-500000 |
| `format` | string | No | Paper size. default A4. One of: A4, Letter, Legal, Tabloid, Ledger, A3, A5, A6. Premium field |
| `landscape` | boolean | No | Set to true for landscape orientation. default false. Premium field |
| `marginTop` | number | No | The top margin in inches. default 0.4. range 0-4. Premium field |
| `marginRight` | number | No | The right margin in inches. default 0.4. range 0-4. Premium field |
| `marginBottom` | number | No | The bottom margin in inches. default 0.4. range 0-4. Premium field |
| `marginLeft` | number | No | The left margin in inches. default 0.4. range 0-4. Premium field |
| `css` | string | No | Stylesheet applied after the default one, so its rules win, e.g. body { font-family: Georgia, serif } table { border-collapse: collapse }. length 0-100000. Premium field |
| `headerTemplate` | string | No | HTML printed at the top of every page. Spans with class pageNumber, totalPages, date or title are filled in. Use inline styles with a font-size (Chromium defaults to a tiny font) and leave room with marginTop. Premium field |
| `footerTemplate` | string | No | HTML printed at the bottom of every page, with the same placeholders as headerTemplate, e.g. <span class="pageNumber"></span> of <span class="totalPages"></span>. Premium field |

## Response fields

- `marginLeft` — string · Left margin dimension of the generated PDF document
- `marginRight` — string · Right margin dimension of the generated PDF document
- `marginTop` — string · Top margin dimension of the generated PDF document
- `marginBottom` — string · Bottom margin dimension of the generated PDF document
- `landscape` — boolean · Indicates whether PDF orientation is landscape format
- `pdfName` — string · Unique filename identifier for the generated PDF
- `expires` — number · Unix timestamp when the PDF download URL expires
- `downloadURL` — string · Direct URL to download the generated PDF document
- `markdownLength` — number · Character count of the input markdown text
- `htmlLength` — number · Character count of the generated HTML intermediate format · (premium)

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "marginLeft": "0.4in",
    "marginRight": "0.4in",
    "marginTop": "0.4in",
    "marginBottom": "0.4in",
    "landscape": false,
    "pdfName": "b3ce14f5-1c44-4d2d-8a10-77430b679dae.pdf",
    "expires": 1766096769188,
    "downloadURL": "https://storage.googleapis.com/apiverve-helpers.appspot.com/htmltopdf/b3ce14f5-1c44-4d2d-8a10-77430b679dae.pdf?GoogleAccessId=1089020767582-compute%40developer.gserviceaccount.com&Expires=1766096769&Signature=q%2Fe4YUCniLQIRCPSO82LhTJ%2BSfqZSPNq8nSblE0LW6%2B546R9kXIowaQD7k%2BOhFzQi9q3nb8QcUNtZijHpEkIIcy6OOayWInWMzMF8ooXQ7Gch4YJL6iAURSIFZpfEw3XqyYuWXP1dw372kmiYVfTBgaRed0apeRwjeF8bGciLm%2FOsYKcsRrYlJtuyFwqeNw4G2aQKgLkxUw%2FP6L5Av%2BZssRkRqIWvQ6eNmwpUJZ48hJZYY6%2BRFhTYwnN4dEPWYSd9TSiJf6C%2BEWReWQJlgBy7BUK0H%2B9pyn4872PV1N3eI9VHhg89g4dimbieOQUF%2BhG%2Bkhcd5z0inaMml7DBdbF4g%3D%3D",
    "markdownLength": 278,
    "htmlLength": 380
  }
}
```

## Use cases

- **Documentation Export** — Convert markdown documentation to PDF for offline distribution
- **PDF Report Generation** — Use it as a PDF creator API to generate reports from markdown-formatted content
- **Resume Building** — Create PDF resumes from markdown source files
- **Publishing Workflows** — Convert markdown articles to PDF for publishing and archiving

## SDKs

- **npm** — `npm install @apiverve/markdowntopdf` (https://www.npmjs.com/package/@apiverve/markdowntopdf)
- **NuGet** — `dotnet add package APIVerve.API.MarkdowntoPDF` (https://www.nuget.org/packages/APIVerve.API.MarkdowntoPDF)
- **Source** — https://github.com/apiverve/markdowntopdf-api

## More

- Full reference: https://docs.apiverve.com/ref/markdowntopdf
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
