HTML and URLs to PDF and images
Send HTML or a URL. Chrome draws it and you get a file URL back. One file is one credit.
HTML to PDF
curl
curl -X POST "https://mintrender.com/v1/convert" \ -H "Authorization: Bearer $MINTRENDER_KEY" \ -H "Content-Type: application/json" \ -d '{"html":"<h1>Invoice 1042</h1><p>Total: £120.00</p>","format":"pdf","pdf":{"size":"A4","margin":{"top":15,"bottom":15},"footer":"Page {{page}} of {{pages}}"}}'JavaScript
const res = await fetch("https://mintrender.com/v1/convert", { method: "POST", headers: { Authorization: `Bearer ${process.env.MINTRENDER_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ html: "<h1>Invoice 1042</h1><p>Total: £120.00</p>", format: "pdf", pdf: { size: "A4", margin: { top: 15, bottom: 15, }, footer: "Page {{page}} of {{pages}}", }, }),});const body = await res.json();if (!res.ok) throw new Error(`${body.error.code}: ${body.error.message} (${body.error.request_id})`);console.log(body);Python
import os import requests res = requests.post( "https://mintrender.com/v1/convert", headers={"Authorization": f"Bearer {os.environ['MINTRENDER_KEY']}"}, json={ "html": "<h1>Invoice 1042</h1><p>Total: £120.00</p>", "format": "pdf", "pdf": { "size": "A4", "margin": { "top": 15, "bottom": 15, }, "footer": "Page {{page}} of {{pages}}", }, }, timeout=120,)body = res.json()if not res.ok: raise RuntimeError(f"{body['error']['code']}: {body['error']['message']} ({body['error']['request_id']})")print(body)The answer is a Render object, like POST /v1/render. Add ?inline=1 to get the file itself. The same HTML and options again come from the stored file at no cost (cached: true).
A web page to an image
curl
curl -X POST "https://mintrender.com/v1/convert" \ -H "Authorization: Bearer $MINTRENDER_KEY" \ -H "Content-Type: application/json" \ -d '{"url":"https://example.com/report","format":"png","image":{"width":1280,"height":800,"full_page":true},"wait":{"until":"network_idle"}}'JavaScript
const res = await fetch("https://mintrender.com/v1/convert", { method: "POST", headers: { Authorization: `Bearer ${process.env.MINTRENDER_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ url: "https://example.com/report", format: "png", image: { width: 1280, height: 800, full_page: true, }, wait: { until: "network_idle", }, }),});const body = await res.json();if (!res.ok) throw new Error(`${body.error.code}: ${body.error.message} (${body.error.request_id})`);console.log(body);Python
import os import requests res = requests.post( "https://mintrender.com/v1/convert", headers={"Authorization": f"Bearer {os.environ['MINTRENDER_KEY']}"}, json={ "url": "https://example.com/report", "format": "png", "image": { "width": 1280, "height": 800, "full_page": True, }, "wait": { "until": "network_idle", }, }, timeout=120,)body = res.json()if not res.ok: raise RuntimeError(f"{body['error']['code']}: {body['error']['message']} ({body['error']['request_id']})")print(body)A URL is drawn again on each call (the page can change), so each call costs a credit.
Fields
| Field | About |
|---|---|
html | The HTML, at most 2 MB. Send html or url. |
url | A public http or https page. Send html or url. |
format | pdf (default), png, jpg or webp. |
css | CSS added to the page. |
pdf.size | A3, A4 (default), A5, Letter, Legal, or {width, height} in millimetres. |
pdf.orientation | portrait (default) or landscape. |
pdf.margin | {top, right, bottom, left} in millimetres. 10 on each side when not set. |
pdf.header, pdf.footer | HTML on each page. {{page}} and {{pages}} give the page numbers. |
pdf.background | Print background colours and pictures. Default true. |
pdf.css_page_size | Use the page's own CSS @page size instead of pdf.size. |
image.width, image.height | The browser window in CSS pixels. Default 1200 × 800, at most 3840 × 2160. |
image.full_page | The whole page, not only the window (at most 16,384 px tall). |
image.scale | 1 or 2: 2 makes a sharper image twice the size. |
image.transparent | PNG and WebP: no white background behind the page. |
wait.until | network_idle (default): no requests for 500 ms. load: the load event. |
wait.selector | Wait until this CSS selector is on the page. |
wait.ms | Wait this many more milliseconds, at most 10,000. |
javascript | Run the page's scripts. Default true. |
mode, webhook_url, metadata, retention_hours | As in POST /v1/render. |
Pictures that did not load
When a picture, font or style does not load, the file is still made, and each output lists what went wrong in warnings: the URL and the reason, like "the server answered 404" or "blocked: a relative address; use a full https:// URL". Use full https:// addresses for pictures in HTML you send.
What a page may load
Every request a page makes is checked before it leaves the browser. A page may load http and https addresses on ports 80 and 443 whose names point to public addresses. It may not load private, local or reserved addresses, or MintRender's own hosts. Fonts you name in CSS load from Google Fonts, and Noto fonts cover Arabic, Hebrew, Devanagari, Thai and CJK text.
Limits and timing
- A page has 30 seconds to load. A PDF has at most 100 pages, and a file at most 25 MB.
- Each workspace runs a set number of browser renders at once: Free 1, Starter 3, Pro 6, Business 12. A sync request waits up to 20 seconds for a place, then answers 429 with
Retry-After. Jobs (mode: "async") wait in the queue instead. - For pages that take long, send
mode: "async"and awebhook_url.
For designs you make in the editor, the fast engine is quicker and exact. See Two engines.
Seen MintRender used for content that breaks our terms? Report it. Questions about the API: support@mintrender.com, with the request id.