Skip to main content
Glama

html_to_pdf

Render HTML documents into PDF files using headless Chromium, supporting full CSS, inline SVG, and print-media queries. Use for invoices, reports, and certificates.

Instructions

Convert an HTML document to a PDF and return it as a base64-encoded string.

Renders the HTML in a headless Chromium browser and exports to PDF.
Supports full CSS (including Flexbox, Grid, custom fonts via Google Fonts),
inline SVG, and print-media-query styles. Page size defaults to A4.

Use for generating invoices, reports, certificates, or any document that
needs to be rendered exactly as it appears in a browser.

Args:
    html: Complete HTML document to convert. Should include a full
          <html><head>...</head><body>...</body></html> structure.
          For best results include a <style> block or link to a CDN CSS.
          Use @media print CSS rules to control page breaks.

Returns:
    Base64-encoded PDF bytes. Decode with base64.b64decode() to get the
    raw PDF binary, which can be written to a file or returned to a user.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
htmlYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

Describes rendering in headless Chromium, CSS support, default A4 page size, and base64 return. No annotations exist, so description carries full burden; it adds sufficient behavioral context but omits potential limitations (e.g., timeouts, resource loading).

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

Conciseness4/5

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

Description is front-loaded with purpose and behavior, followed by structured Args and Returns sections. It is slightly longer than necessary but well-organized and free of repetition.

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

Completeness4/5

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

Covers purpose, parameter details, behavioral notes, and return format. With an output schema present, it does not need to detail PDF structure. Missing minor aspects like error handling or dependency on external resources (e.g., fonts).

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?

Despite 0% schema coverage, the description's Args section fully explains the html parameter: expects a complete HTML document, recommends style block and @media print CSS. This adds rich context beyond the schema's minimal type definition.

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

Purpose4/5

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

Clearly states it converts HTML to PDF and returns base64 string. Specifies use cases (invoices, reports) but does not explicitly differentiate from sibling tools like screenshot_url.

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

Usage Guidelines3/5

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

Provides typical use cases but no guidance on when not to use or alternatives. Context signals show siblings like screenshot_url cover similar needs, but no exclusion criteria are mentioned.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ForeverTools/kiprio-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server