Convert HTML to PDF
convert_htmlConvert HTML markup to PDF documents using Chromium rendering. Supports custom CSS, page sizes, margins, and orientation for tailored PDF output.
Instructions
Render a raw HTML string to a PDF using Chromium, with optional CSS and layout options. Costs 1 credit on success. Returns the PDF as an embedded resource.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| html | Yes | The HTML markup to render. | |
| css | No | Optional CSS, injected into the document <head>. | |
| landscape | No | Render in landscape orientation. (Pro/Scale/trial only.) | |
| paperWidth | No | Paper width in inches, or with a unit e.g. "210mm". | |
| paperHeight | No | Paper height in inches. | |
| marginTop | No | Top margin in inches. | |
| marginBottom | No | Bottom margin in inches. | |
| marginLeft | No | Left margin in inches. | |
| marginRight | No | Right margin in inches. | |
| scale | No | Render scale, 0.1–2.0. | |
| printBackground | No | Print background graphics/colors. | |
| preferCssPageSize | No | Use the page size declared in CSS @page rules. | |
| nativePageRanges | No | Page ranges to include, e.g. "1-3,5". | |
| pdfa | No | PDF/A conformance level, e.g. "PDF/A-2b". (Pro/Scale/trial only.) | |
| pdfua | No | Produce an accessible PDF/UA document. | |
| userPassword | No | Password required to open the resulting PDF. | |
| ownerPassword | No | Owner password controlling permissions on the resulting PDF. | |
| save_path | No | Optional absolute path to also write the PDF to on disk. |