---
title: "Convert HTML, Markdown & URL to PDF API"
slug: convert-html-md-url-to-pdf
url: https://apyhub.com/sarvasoft/service/convert-html-md-url-to-pdf
provider: SARVASOFT OPC PRIVATE LIMITED
categories: [Ingestion Kit, Output Kit, Media Kit]
tags: [web-to-pdf, screenshot, html-rendering, page-capture, pdf-generation]
auth: api_key
version: 2.0.0
service_type: sync
endpoints: 1
atoms: 10
mcp: true
---

# Convert HTML, Markdown & URL to PDF API

Screenshot to PDF API: send HTML, Markdown or a URL and get a PDF that looks exactly like the page, full page or viewport. Free tier, no card.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| POST | `https://api.eu.apyhub.com/sarvasoft/convert-html-md-url-to-pdf/screenshot/pdf` | What it does Takes a screenshot of a web page, raw HTML or Markdown in Chromium and returns it as a… | 10 |

## Endpoint reference

### Capture screenshot then convert to PDF

`POST https://api.eu.apyhub.com/sarvasoft/convert-html-md-url-to-pdf/screenshot/pdf` · 10 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `url` | body | string (uri) | no | Public web page to capture as a PDF. Must be http or https. Provide exactly one of url, html or markdown. Example: `https://example.com`. |
| `html` | body | string | no | Raw HTML to render and capture as a PDF. Provide exactly one of url, html or markdown. Example: `<h1 style='font-family:Arial'>Hello</h1>`. |
| `width` | body | integer | no | Viewport width in pixels. Default: `1280`. Example: `1280`. |
| `height` | body | integer | no | Viewport height in pixels. Default: `720`. Example: `720`. |
| `cookies` | body | array of object | no | Cookies set in the browser before loading the page. Example: `[{"name":"session","value":"abc123","domain":"example.com"}]`. |
| `scripts` | body | array of string | no | Inline scripts or script URLs to run before capture. Example: `["document.querySelector('.cookie-banner')?.remove()"]`. |
| `timeout` | body | integer | no | Load and capture timeout in milliseconds. Default: `30000`. Example: `30000`. |
| `filename` | body | string | no | Name of the PDF file. Example: `homepage.pdf`. |
| `markdown` | body | string | no | Markdown to convert to HTML, render and capture as a PDF. Provide exactly one of url, html or markdown. Example: `# Release notes

- Faster exports`. |
| `auth_type` | body | string | no | Login used when loading url. One of: none, basic, bearer. Default: `none`. Example: `basic`. |
| `full_page` | body | boolean | no | Capture the full scrollable page into the PDF, not only the viewport. Default: `false`. Example: `true`. |
| `style_url` | body | string | no | Public URL of a CSS file to load before capture. Example: `https://example.com/capture.css`. |
| `custom_css` | body | string | no | CSS injected into the page before capture. Example: `.cookie-banner { display: none; }`. |
| `script_url` | body | string | no | Public URL of a JavaScript file to load before capture. Example: `https://example.com/setup.js`. |
| `wait_until` | body | string | no | When the page counts as loaded. One of: load, domcontentloaded, networkidle, networkidle0, networkidle2. Default: `networkidle`. Example: `networkidle`. |
| `image_format` | body | string | no | Format of the screenshot placed inside the PDF. jpeg gives a smaller file, png keeps sharper text. One of: png, jpeg. Default: `png`. Example: `png`. |
| `extra_headers` | body | object | no | Extra HTTP headers sent when loading url. Example: `{"Accept-Language":"en-GB"}`. |
| `response_mode` | body | string | no | How the PDF is returned: binary (the file itself), base64, json (base64 plus size and creation time) or url (a temporary download link). One of: binary, base64, json, url. Default: `binary`. Example:… |
| `auth_credentials` | body | string | no | Login value for auth_type: username:password for basic, the token for bearer. Example: `user:secret`. |
| `wait_for_timeout` | body | integer | no | How long to wait for the selector or function, in milliseconds. Example: `5000`. |
| `wait_for_function` | body | string | no | JavaScript expression to wait for until it is true. Example: `document.fonts.status === 'loaded'`. |
| `wait_for_selector` | body | string | no | CSS selector to wait for before capture. Example: `#hero`. |
| `execute_javascript` | body | boolean | no | Run the page's JavaScript before capture. Default: `true`. Example: `true`. |

#### Quickstart

Render a page to a PDF from a URL with the default viewport settings.

```bash
curl -X POST "https://api.eu.apyhub.com/sarvasoft/convert-html-md-url-to-pdf/screenshot/pdf" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://apyhub.com"
  }'
```

#### What you'll get back

Returns a JSON object in one of the shapes declared by `response_mode`:

- `response_mode=base64`: a JSON object with `filename` and `pdf_base64`
- `response_mode=json`: a JSON object with `filename`, `size`, `created_at`, and `pdf_base64`
- `response_mode=url`: a JSON object with `file_url`, `expires_at`, and `expires_in_seconds`

Example for the `url` shape:


```json
{
  "filename": "screenshot.pdf",
  "size": 770,
  "created_at": "2026-01-15T10:30:00Z",
  "pdf_base64": "JVBERi0xLjcKJb/3ov4KMSAwIG9iago8PCAvVHlwZSAvT2JqU3RtIC9MZW5ndGggMjI5..."
}
```

## About

## What it does
The Convert HTML, Markdown & URL to PDF API is a webpage screenshot to PDF API. It saves a web page, HTML or Markdown as a PDF that looks exactly like the screen. Send one of `url`, `html` or `markdown`, and get back a PDF that holds a Chromium screenshot of the page.

Set the viewport with `width` and `height` (defaults `1280` by `720`). Turn on `full_page` to put the whole scrollable page into the PDF. `image_format` sets the screenshot inside the PDF: `png` keeps text sharp, `jpeg` gives a smaller file.

For live pages, `wait_until` and `wait_for_selector` hold the capture until content loads. `custom_css` and `scripts` can hide cookie banners first. `cookies`, `extra_headers` and `auth_type` reach pages behind a login. `response_mode` returns the PDF as a file by default. It can also return base64, JSON with size and time, or a temporary download link.

Teams use it to keep visual records of web pages and to save dashboards and receipts for audits. It also sends page snapshots to people who expect a PDF.

A webpage screenshot to PDF API stores the page as one image, so its text cannot be selected or searched. For a PDF with searchable text and page layout options, use the [Convert HTML & Markdown to PDF API](https://apyhub.com/sarvasoft/service/convert-html-markdown-to-pdf) instead.

To brand the result, the [PDF Watermark API](https://apyhub.com/apyhub/service/apply-watermark-on-pdf) stamps text or a logo on it. The [Merge Files to PDF API](https://apyhub.com/apyhub/service/merge-files-to-pdf) combines several captures into one file.

AI agents can call it through ApyHub MCP.

## Usage

Base URL: `https://api.eu.apyhub.com` (default region — see
`GET https://apyhub.com/api/public/regions` for the rest).

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/sarvasoft/service/convert-html-md-url-to-pdf
