---
title: Convert HTML File to PDF API
slug: convert-html-file-to-pdf
url: https://apyhub.com/frolic/service/convert-html-file-to-pdf
provider: Hakimi Labs
categories: [Document Intelligence Kit, Output Kit]
tags: [html-to-pdf, pdf-generation, document-conversion, pdfa, web-to-pdf]
auth: api_key
version: 1.0
service_type: sync
endpoints: 1
atoms: 25
mcp: true
---

# Convert HTML File to PDF API

Convert an HTML string or file into a PDF binary with page size, margins, headers, footers, and PDF/A options. Useful for reports, invoices, and archived web pages.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| POST | `https://api.eu.apyhub.com/frolic/convert-html-file-to-pdf/html-to-pdf` | What it does Converts an HTML document into a PDF file and returns the generated PDF as binary data… | 25 |

## Endpoint reference

### HTML to PDF

`POST https://api.eu.apyhub.com/frolic/convert-html-file-to-pdf/html-to-pdf` · 25 atoms · accepts `multipart/form-data` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `file` | body | string (binary) | no | The HTML document as a file, instead of html |
| `html` | body | string | no | The HTML document Example: `<h1>Hello, world!</h1>`. |
| `pdfa` | body | string | no | Archival format: PDF/A-1b, PDF/A-2b or PDF/A-3b One of: PDF/A-1b, PDF/A-2b, PDF/A-3b. |
| `paper` | body | string | no | A3, A4 (default), A5, A6, Letter, Legal or Tabloid One of: A3, A4, A5, A6, Letter, Legal, Tabloid. |
| `assets` | body | array of string | no | Up to 20 files the HTML references by name, e.g. logo.png or style.css |
| `landscape` | body | boolean | no | Landscape pages (default false) |
| `margin_top` | body | number (double) | no | Top margin in inches (0-4, default 0.39) |
| `wait_delay` | body | integer (int32) | no | Seconds to wait after the page loads, for JavaScript-heavy pages (0-10) |
| `footer_html` | body | string | no | HTML repeated at the bottom of every page; same placeholders as header_html |
| `header_html` | body | string | no | HTML repeated at the top of every page. <span class="pageNumber"></span> and <span class="totalPages"></span> are filled in |
| `margin_left` | body | number (double) | no | Left margin in inches (0-4, default 0.39) |
| `margin_right` | body | number (double) | no | Right margin in inches (0-4, default 0.39) |
| `margin_bottom` | body | number (double) | no | Bottom margin in inches (0-4, default 0.39) |
| `print_background` | body | boolean | no | Print background colours and images (default true) |

#### Quickstart

Convert an HTML file or HTML string into a PDF by sending the required multipart form field.

```bash
curl -X POST "https://api.eu.apyhub.com/frolic/convert-html-file-to-pdf/html-to-pdf" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/document.html"
```

#### What you'll get back

Returns a binary file (`string` with `format: binary`) — the generated PDF content.

## About

## What it does
HTML to PDF converts HTML into a PDF binary you can store, email, or hand off to another workflow. Send either an `html` string or a `file` containing the HTML document, and get a PDF file back.

Use `paper` to choose the page size, `landscape` for orientation, and `print_background` when you need backgrounds and images preserved in the output. If you are generating archival documents, set `pdfa` to one of `PDF/A-1b`, `PDF/A-2b`, or `PDF/A-3b`.

For rendered pages that depend on JavaScript, `wait_delay` gives the page time to finish loading before conversion. You can also attach up to 20 referenced `assets` such as images or stylesheets, and set `header_html` or `footer_html` for repeated content on every page. Margins are configurable on all sides, including `margin_top`, `margin_bottom`, `margin_left`, and `margin_right`.

Use HTML to PDF when you need invoices, reports, receipts, or printable previews from application content without building a separate document pipeline.

## 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/frolic/service/convert-html-file-to-pdf
