Skip to main content
Glama

html_to_pdf

Convert HTML and CSS to a PDF document using the WeasyPrint rendering engine. Supports every PDF/A archival level, PDF/UA accessibility and the PDF/X print standards. Best for professional documents: invoices, reports, certificates, contracts, and accessible documents. Also produces fillable PDF forms — set pdfForms to true. Send a complete HTML document including , with , and tags. Page geometry comes from the document's own CSS @page rule unless paperSize or orientation is set explicitly. Returns a temporary download URL for the generated PDF (valid for 30 minutes). Requires a paid PdfBroker.io plan (Starter or above). EU-first defaults: A4 paper, Portrait orientation when neither the document nor the caller says otherwise.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "html_to_pdf"
  }
}

Input Schema

NameRequiredDescriptionDefault
urlNoOptional https URL of an already published HTML document, fetched by PdfBroker instead of sending the markup inline. Use this to keep a large template out of the conversation. Only https is accepted, and addresses on private networks or cloud metadata endpoints are refused. If both 'url' and 'html' are supplied, 'url' wins. Relative images, fonts and stylesheets in the document resolve against the document's own URL, so the 'resources' parameter has no effect on a url render. paperSize and orientation cannot be applied to a url render with this engine — the published document's own @page rule decides.
htmlNoComplete HTML document string including <html>, <head>, <style>, and <body> tags. Use CSS for styling. WeasyPrint supports CSS Paged Media for headers, footers, and page numbers via @page margin boxes. Optional if 'url' is supplied instead — pass exactly one of the two.
pdfFormsNoSet to true to produce a fillable PDF: the document's <input>, <select> and <textarea> elements become interactive form fields a recipient can type into and save. Default false, which flattens them into static text. Note that form fields and strict tagging can interact — if the engine refuses a combination of forms and a conformanceLevel, its message is returned as-is.
paperSizeNoPaper size: 'Auto' (default) leaves the page to the document's own CSS — an @page rule such as '@page { size: A5 landscape; }' decides, and when the document says nothing you get A4 portrait (EU-first default). Name a size to override the document: 'A4' (210x297mm), 'Letter' (8.5x11in), 'A3' (297x420mm), 'Legal' (8.5x14in). An explicitly named size wins over the document's own @page rule.Auto
resourcesNoOptional embedded resources referenced by relative path in the HTML (images, custom fonts via @font-face, stylesheets, etc.). Keys are relative paths (e.g., 'images/logo.png'), values are base64-encoded file contents. Unused entries are silently ignored. Invalid base64 returns a clear, key-named error before the API call is made.
orientationNoPage orientation: 'Auto' (default) leaves it to the document's CSS, 'Portrait' or 'Landscape' override it. Combine with paperSize for a full override, or use it alone to rotate whatever size the document declares.Auto
extraArgumentsNoOptional extra WeasyPrint engine arguments forwarded verbatim to the engine. Keys are CLI long-form options without '--'. For switch-style flags use an empty-string value — example: {"presentational-hints": ""}. On key collision with structured parameters (conformanceLevel, paperSize, orientation), the user-supplied extra wins. See the docs://pdfbroker/api-reference resource for the supported argument list.
conformanceLevelNoPDF compliance standard. 'None' (default) requests no conformance. Archival, level B — visual fidelity: 'PdfA1b' (widest compatibility), 'PdfA2b', 'PdfA3b' (allows embedded attachments, used for e-invoicing). Archival, level U — level B plus guaranteed Unicode text extraction: 'PdfA2u', 'PdfA3u'. Archival, level A — level U plus a tagged structure tree, so the file is archival AND accessible in one document: 'PdfA1a', 'PdfA2a', 'PdfA3a'. PDF/A-4 (PDF 2.0, thinner reader support): 'PdfA4u' (baseline), 'PdfA4f' (embedded files), 'PdfA4e' (engineering). Note there is no PDF/A-4b — PDF/A-4 dropped the A/B lettering. Accessibility: 'PdfUA1' (European Accessibility Act; use this unless UA-2 was asked for), 'PdfUA2'. Print production: 'PdfX1a', 'PdfX3', 'PdfX4', 'PdfX5g'. The raw engine value is also accepted (e.g. 'pdf/a-2b'). Use PdfUA1 when the document must be accessible to screen readers, and PdfA2a when it must be both archival and accessible. An unknown value is rejected rather than silently ignored.None

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed10 schema fields changed
    • addedInput schema / properties / html / default
      Added value: +null
    • changedInput schema / properties / html / description
      Previous value: -"Complete HTML document string including <html>, <head>, <style>, and <body> tags. Use CSS for styling. WeasyPrint supports CSS Paged Media for headers, footers, and page numbers via @page margin boxes."New value: +"Complete HTML document string including <html>, <head>, <style>, and <body> tags. Use CSS for styling. WeasyPrint supports CSS Paged Media for headers, footers, and page numbers via @page margin boxes. Optional if 'url' is supplied instead — pass exactly one of the two."
    • changedInput schema / properties / html / type
      Previous value: -"string"New value: +[
      +  "string",
      +  "null"
      +]
    • changedInput schema / properties / orientation / default
      Previous value: -"Portrait"New value: +"Auto"
    • changedInput schema / properties / orientation / description
      Previous value: -"Page orientation: 'Portrait' (default) or 'Landscape'"New value: +"Page orientation: 'Auto' (default) leaves it to the document's CSS, 'Portrait' or 'Landscape' override it. Combine with paperSize for a full override, or use it alone to rotate whatever size the document declares."
    • changedInput schema / properties / paperSize / default
      Previous value: -"A4"New value: +"Auto"
    • changedInput schema / properties / paperSize / description
      Previous value: -"Paper size: 'A4' (default, EU-first, 210x297mm), 'Letter' (8.5x11in), 'A3' (297x420mm), 'Legal' (8.5x14in)"New value: +"Paper size: 'Auto' (default) leaves the page to the document's own CSS — an @page rule such as '@page { size: A5 landscape; }' decides, and when the document says nothing you get A4 portrait (EU-first default). Name a size to override the document: 'A4' (210x297mm), 'Letter' (8.5x11in), 'A3' (297x420mm), 'Legal' (8.5x14in). An explicitly named size wins over the document's own @page rule."
    • addedInput schema / properties / pdfForms
      Added value: +{
      +  "default": false,
      +  "description": "Set to true to produce a fillable PDF: the document's <input>, <select> and <textarea> elements become interactive form fields a recipient can type into and save. Default false, which flattens them into static text. Note that form fields and strict tagging can interact — if the engine refuses a combination of forms and a conformanceLevel, its message is returned as-is.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / url
      Added value: +{
      +  "default": null,
      +  "description": "Optional https URL of an already published HTML document, fetched by PdfBroker instead of sending the markup inline. Use this to keep a large template out of the conversation. Only https is accepted, and addresses on private networks or cloud metadata endpoints are refused. If both 'url' and 'html' are supplied, 'url' wins. Relative images, fonts and stylesheets in the document resolve against the document's own URL, so the 'resources' parameter has no effect on a url render. paperSize and orientation cannot be applied to a url render with this engine — the published document's own @page rule decides.",
      +  "type": [
      +    "string",
      +    "null"
      +  ]
      +}
    • removedInput schema / required
      Removed value: -[
      -  "html"
      -]
  2. Changed1 schema field changed
    • changedInput schema / properties / conformanceLevel / description
      Previous value: -"PDF compliance standard. Values: 'None' (default — no compliance), 'PdfA1b' (archival, maps to pdf/a-1b), 'PdfA3b' (archival with attachments, maps to pdf/a-3b), 'PdfUA1' (accessibility, European Accessibility Act, maps to pdf/ua-1). Use PdfUA1 when the document must be accessible to screen readers."New value: +"PDF compliance standard. 'None' (default) requests no conformance. Archival, level B — visual fidelity: 'PdfA1b' (widest compatibility), 'PdfA2b', 'PdfA3b' (allows embedded attachments, used for e-invoicing). Archival, level U — level B plus guaranteed Unicode text extraction: 'PdfA2u', 'PdfA3u'. Archival, level A — level U plus a tagged structure tree, so the file is archival AND accessible in one document: 'PdfA1a', 'PdfA2a', 'PdfA3a'. PDF/A-4 (PDF 2.0, thinner reader support): 'PdfA4u' (baseline), 'PdfA4f' (embedded files), 'PdfA4e' (engineering). Note there is no PDF/A-4b — PDF/A-4 dropped the A/B lettering. Accessibility: 'PdfUA1' (European Accessibility Act; use this unless UA-2 was asked for), 'PdfUA2'. Print production: 'PdfX1a', 'PdfX3', 'PdfX4', 'PdfX5g'. The raw engine value is also accepted (e.g. 'pdf/a-2b'). Use PdfUA1 when the document must be accessible to screen readers, and PdfA2a when it must be both archival and accessible. An unknown value is rejected rather than silently ignored."
  3. First observed

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations provided, the description carries full responsibility for disclosing behavior. It reveals several non-obvious traits: the ability to produce fillable PDF forms via pdfForms, the 30-minute expiration of returned URLs, the requirement for a paid plan, the interaction between forms and conformanceLevel, the silent ignoring of unused resources, the clear error handling for invalid base64, and the rejection (rather than silent ignoring) of unknown conformanceLevel values. These disclosures exceed what any typical annotation would cover, making this dimension exemplary.

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

Conciseness5/5

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

The description is long but every sentence earns its place. It is front-loaded with the core purpose and audience, then progressively details parameters, constraints, and defaults. Each paragraph handles a distinct aspect (rendering, forms, input requirements, geometry, output, plan requirement, regional defaults). There is no fluff or redundant phrasing; it is dense but readable, striking an effective balance between comprehensiveness and organization.

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?

Given the tool's complexity (8 parameters, no annotations, no output schema), the description is remarkably complete. It fully explains all parameters, their interactions, and edge cases. It also describes the output format (temporary download URL with expiry) even though no output schema exists. It covers prerequisites (paid plan), input requirements (complete HTML), and regional defaults. There are no apparent gaps in what an agent needs to know to correctly invoke the tool.

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

Parameters5/5

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

Schema description coverage is 100%, so the baseline is 3. The description adds substantial semantic value: it explains the precedence of url over html, the default behavior when neither paperSize nor orientation is set, how resources resolve relative to the document's URL, the EU-first A4/portrait defaults, and the detailed taxonomy of conformance levels with concrete recommendations (e.g., use PdfUA1 for accessibility, PdfA2a for archival+accessible). It also clarifies the effect of the extraArguments key collision rule. This goes far beyond simply restating the schema, so a 5 is appropriate.

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?

The description opens with a clear verb-resource pair: 'Convert HTML and CSS to a PDF document using the WeasyPrint rendering engine.' It names the specific engine, implying distinction from the sibling tool (html_to_pdf_wk), and enumerates typical use cases (invoices, reports, certificates, contracts, accessible documents). This goes beyond a generic purpose statement and clearly informs the agent what the tool accomplishes.

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

Usage Guidelines4/5

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

The description provides strong usage context: it states best-fit document types, requires a complete HTML document structure, explains how page geometry is determined, and calls out the paid-plan prerequisite. It also clarifies when to use url vs. inline html. However, it does not explicitly mention the sibling tool or offer guidance on when to prefer this over html_to_pdf_wk, so the when-not-to-use and alternative dimension is missing. A 4 is warranted for clear context without exclusions.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources