Create a PDF from HTML
pdf_html_to_pdfRender an HTML string to PDF using a headless browser so CSS, web fonts, images, and print styles match browser output; JavaScript does not run and URL input is not accepted.
Instructions
Render an HTML string to a PDF with a headless browser, so layout, CSS (flexbox, grid, print styles), images and web fonts come out as in a browser print. It takes HTML text only: there is no URL input, and JavaScript is switched off, so scripts do not run and pages that build themselves with JavaScript render empty. External resources (images, stylesheets, fonts) load only over https from public hosts; anything else (http, file, private or internal addresses, redirects to them) is blocked and skipped, and the PDF is still made. Data URIs work and are the safest way to include images. Letter or A4, portrait or landscape, margin in points (default 36), backgrounds printed by default, optional scale. html is capped at 1 MB, the document at 50 pages and 16 MB, external resources at 50 requests and 40 MB, and rendering at 15 seconds. Frames, iframes, objects, embeds, audio and video are not rendered, and an inline or fetched image is decoded and checked first. Common fonts (Helvetica, Arial, Times, Courier and generic families) render as Liberation faces, metric-compatible with the originals. Once the renderer is reached every outcome costs 5 of your monthly request quota, not 1, failures included; a cheap refusal before a browser starts (for example an inline image refused: image_too_large or unsupported_image, with the image named in the message) costs 1; only input validation errors and a busy or unreachable renderer cost nothing. Images: 16 megapixels at most each (96 in total), PNG, JPEG, GIF, WebP or SVG (simplified: scripts, style sheets, filters, masks, embedded images and links are removed; inline style colours are kept); AVIF, BMP, ICO, TIFF, animated PNG and colour-bitmap fonts are not supported, and an image in an unsupported format or over a limit fails the request (a missing image, such as a 404 or a tracking pixel, is skipped). For Markdown, text or CSV with no HTML use pdf_text_to_pdf; to build an invoice from data use pdf_invoice. Returns the result written to output_path, or inline as an application/pdf resource when output_path is omitted (results over 7 MB are never returned inline: pass output_path); an existing file at output_path is overwritten. The source is never modified.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"html": "<html>"
},
"name": "pdf_html_to_pdf"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| html | Yes | The document as HTML text, up to 1 MB of UTF-8. A full document or a fragment. | |
| scale | No | Page content scale, 0.1-2. Default 1. | |
| margin | No | Margin on every side in points, 0-144. Default 36. | |
| landscape | No | Landscape orientation. Default false. | |
| page_size | No | Default letter. | |
| output_path | No | Path of a .pdf file to write the result to, inside the allowed directories (PDFOPS_ROOT, default the working directory); an existing file there is overwritten. Omit when running remotely: the PDF is then returned inline as an application/pdf resource for the client to save. | |
| print_background | No | Print background colors and images. Default true. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bytes | Yes | Size of the produced PDF in bytes | |
| pages | No | Pages in the PDF | |
| output_path | No | Absolute path written, when output_path was supplied | |
| resource_uri | No | pdfops:// uri of the inline application/pdf resource, when output_path was omitted | |
| blocked_requests | No | External requests the page made that were blocked by the network policy |