Skip to main content
Glama

Create a PDF from HTML

pdf_html_to_pdf
DestructiveIdempotent

Render 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

NameRequiredDescriptionDefault
htmlYesThe document as HTML text, up to 1 MB of UTF-8. A full document or a fragment.
scaleNoPage content scale, 0.1-2. Default 1.
marginNoMargin on every side in points, 0-144. Default 36.
landscapeNoLandscape orientation. Default false.
page_sizeNoDefault letter.
output_pathNoPath 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_backgroundNoPrint background colors and images. Default true.

Output Schema

NameRequiredDescriptionDefault
bytesYesSize of the produced PDF in bytes
pagesNoPages in the PDF
output_pathNoAbsolute path written, when output_path was supplied
resource_uriNopdfops:// uri of the inline application/pdf resource, when output_path was omitted
blocked_requestsNoExternal requests the page made that were blocked by the network policy

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.5.0

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Far beyond what the annotations convey: JavaScript disabled, https-only public external resources with http/file/private addresses skipped, limits (1 MB HTML, 50 pages/16 MB, 50 requests/40 MB, 15 s), blocked embeds, and detailed image format/size handling with per-error-cost semantics. It also documents that quota cost jumps to 5 once the renderer is reached, failures included, which no annotation field expresses. Overwrite of an existing output_path is disclosed consistently with destructiveHint=true, and 'the source is never modified' is a useful clarifying constraint.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose and the sibling routing are correctly front-loaded, and most sentences carry decision-relevant information. However, it is one very dense unbroken block, and a meaningful portion restates schema defaults (page size options, margin default 36, backgrounds default true, scale range) that the agent already has.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex, quota-charged rendering tool with an output schema and annotations, nothing material is missing: input constraints, network policy, resource/format limits, failure-mode costs, and return behavior (inline resource vs output_path) are all covered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning: data URIs as the safest image channel, backgrounds printed by default, margin in points at default 36, and the inline-vs-output_path tradeoff including the 7 MB inline ceiling. It does repeat several schema defaults (A4/letter, scale, margin, backgrounds), which dilutes the added value slightly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Render an HTML string to a PDF with a headless browser') and immediately scopes the input type by ruling out URL input and JavaScript-built pages. It also names the exact siblings to use instead (pdf_text_to_pdf, pdf_invoice), so an agent can separate it from the rest of the catalog without opening a schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit routing is given: Markdown/text/CSV go to pdf_text_to_pdf, invoice-from-data goes to pdf_invoice, and HTML-only is stated twice ('takes HTML text only', 'no URL input'). Exclusion conditions are concrete, including the case where JS-rendered pages would silently come out empty.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.