# PDF tools

> Convert an HTML page to PDF, merge several PDFs or split one, through the API and without keeping anything.

Three API calls work without a template, for the PDFs your software already produces. The files arrive in the call and the PDF goes back in the response: Mizanpage keeps neither the page, nor the files, nor the result. They are open to the plans with the API (Team and above).

## Convert an HTML page to PDF

`POST /v1/pdf/html` takes a complete HTML page and returns its PDF.

```bash
curl -X POST https://api.mizanpage.com/v1/pdf/html \
  -H "Authorization: Bearer mzp_…" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: delivery-2026-118" \
  -d '{"html": "<!doctype html><html><head><meta charset=\"utf-8\"></head><body><h1>Delivery note 2026-118</h1></body></html>", "paper": "A4", "margins": 15}' \
  -o delivery.pdf
```

| Field | Default | Role |
| --- | --- | --- |
| `html` | (required) | The page, 10 MB at most. |
| `paper` | `A4` | `A3`, `A4`, `A5`, `Letter`, `Legal`, or `{"width": 100, "height": 150}` in millimetres. |
| `landscape` | `false` | The paper turned sideways. |
| `margins` | 10 mm | One number for all four sides, or `top`, `right`, `bottom`, `left`. |
| `css_page_size` | `false` | The size in your CSS `@page` rule wins over `paper`. |
| `print_background` | `true` | Background colours and images are printed. |

The page must contain everything it shows: CSS in the page, images and fonts as `data:` URLs. Because the renderer opens no external address, a remote image does not appear.

Each conversion counts as a generated PDF, like a document made from a template. It goes into your plan's quota and then into the overage, appears in the statistics and triggers the `document.generated` webhook. With the same `Idempotency-Key`, a retry is counted only once ([Retrying a call](https://mizanpage.com/en/docs/api/idempotence.md)). With a test key, the PDF is free and carries the Mizanpage logo; during the free trial, it is counted and carries the logo. In both cases, the page's scripts do not run.

## Merge PDFs

`POST /v1/pdf/merge` joins 2 to 20 PDFs into one, in the order sent. Each file travels as base64.

```json
{ "pdfs": ["JVBERi0xLjcK…", "JVBERi0xLjQK…"] }
```

## Split a PDF

`POST /v1/pdf/split` takes a PDF in base64 and exactly one of these options:

| Option | Example | Response |
| --- | --- | --- |
| `pages` | `"1-3,5,8-"` | One PDF with these pages, in this order. |
| `ranges` | `["1-2", "3-"]` | A ZIP with one PDF per range (`part-01.pdf`, `part-02.pdf`…). |
| `every` | `1` | A ZIP with one PDF every N pages. |

The first page is page 1. An open range such as `8-` runs to the last page.

## With an SDK

The [official SDKs](https://mizanpage.com/en/docs/api/sdk.md) send the files in base64 for you. In JavaScript:

```js
const { pdf } = await mizanpage.pdf.fromHtml(html, { paper: 'A4', margins: 15 }, { idempotencyKey: 'BL-2026-118' });
const dossier = await mizanpage.pdf.merge([facture, conditions]);
const zip = await mizanpage.pdf.split(dossier, { every: 1 });
```

In the other languages: `pdf.from_html` and `pdf.split(…, pages=…)` in Python and Ruby, `pdf().fromHtml` in Java and PHP (`pdf()->fromHtml`), `Pdf.FromHtmlAsync` in C#.

## Limits

Merging and splitting are free up to 300 calls an hour per workspace. A call's body weighs 20 MB at most, about 15 MB of PDF once in base64. A file that is not a readable PDF, or that is password-protected, is refused with the `invalid_pdf` error ([Errors](https://mizanpage.com/en/docs/api/erreurs-limites.md)).

---

Documentation Mizanpage · Developers › API
https://mizanpage.com/en/docs/api/outils-pdf/
