Elysia Tools Docs
EN
Language
ZHESPTRUFRDEEN
Back to site
Browse tools

Document Tools

HTML to PDF (Precise Layout)

Render HTML/CSS to a PDF with precise headers, footers, and print settings

file· File resultOpen tool

Quick start

Call this tool from your code in three languages.

cURL
curl -X POST 'https://api.elysiatools.com/en/api/tools/html-to-pdf-precise' \
  -H 'Content-Type: application/json' \
  -d '{"htmlContent":"<h1>Hello PDF</h1><p>Write your HTML here...</p>","cssContent":"/* Optional custom styles */","pageSize":"A4","landscape":false,"printBackground":true,"scale":1,"marginTop":20,"marginBottom":20,"marginLeft":20,"marginRight":20,"headerTemplate":"<div style=\"font-size:10px; width:100%; text-align:center;\"><span class=\"pageNumber\"></span>1/20<span class=\"totalPages\"></span></div>","footerTemplate":"<div style=\"font-size:10px; width:100%; text-align:center;\">Confidential</div>","mediaType":"print","waitUntil":"networkidle0","waitTime":3000,"preferCssPageSize":false}'

© 2026 Elysia Tools. Developer documentation.

Back to siteBrowse tools

API reference

Send a POST request with your inputs as JSON. File parameters require a separate upload first.

Endpoint

HTTP
POST https://api.elysiatools.com/en/api/tools/html-to-pdf-precise

Parameters

NameTypeRequiredDescription
htmlContenttextareaYes—
cssContenttextareaNo—
pageSizeselectNo—
landscapecheckboxNo—
printBackgroundcheckboxNo—
scalenumberNo—
marginTopnumberNo—
marginBottomnumberNo—
marginLeftnumberNo—
marginRightnumberNo—
headerTemplatetextareaNo—
footerTemplatetextareaNo—
mediaTypeselectNo—
waitUntilselectNo—
waitTimenumberNo—
preferCssPageSizecheckboxNo—

Response format

File result

JSON
{
  "filePath": "/public/processing/randomid.ext",
  "fileName": "output.ext",
  "contentType": "application/octet-stream",
  "size": 1024,
  "metadata": {
    "key": "value"
  },
  "error": "Error message (optional)",
  "message": "Notification message (optional)"
}

MCP integration

Add this tool to your Model Context Protocol server so AI agents can list and call it.

Server configuration

Add this block to your MCP client configuration:

mcp.json
{
  "mcpServers": {
    "elysiatools-html-to-pdf-precise": {
      "name": "html-to-pdf-precise",
      "description": "Render HTML/CSS to a PDF with precise headers, footers, and print settings",
      "baseUrl": "https://api.elysiatools.com/mcp/sse?toolId=html-to-pdf-precise",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

List available tools

After connecting to the SSE endpoint, list the exposed tools:

tools/list
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/list"
}

Call this tool

Invoke the tool by its id, passing arguments built from its parameters:

tools/call
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "html-to-pdf-precise",
    "arguments": {
  "htmlContent": "<h1>Hello PDF</h1><p>Write your HTML here...</p>",
  "cssContent": "/* Optional custom styles */",
  "pageSize": "A4",
  "landscape": false,
  "printBackground": true,
  "scale": 1,
  "marginTop": 20,
  "marginBottom": 20,
  "marginLeft": 20,
  "marginRight": 20,
  "headerTemplate": "<div style=\"font-size:10px; width:100%; text-align:center;\"><span class=\"pageNumber\"></span>1/20<span class=\"totalPages\"></span></div>",
  "footerTemplate": "<div style=\"font-size:10px; width:100%; text-align:center;\">Confidential</div>",
  "mediaType": "print",
  "waitUntil": "networkidle0",
  "waitTime": 3000,
  "preferCssPageSize": false
}
  }
}
Chain multiple tools in one session with a comma-separated toolId list, e.g. /mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp (max 20).

Questions or issues? Contact [email protected]

Browse tools
Open tool