HTML to PDF (Precise Layout)
Render HTML/CSS to a PDF with precise headers, footers, and print settings
This tool renders HTML/CSS to PDF using a headless browser for high-fidelity layout.
**Header & Footer:**
- Provide custom HTML templates for headers/footers
- Use `<span class="pageNumber"></span>` and `<span class="totalPages"></span>` for page numbers
- CSS in header/footer is supported with inline styles
**Print Options:**
- A4/Letter/Legal page sizes
- Margin control (mm)
- Print background and scaling
- CSS `@page` and `@media print` support (enable "Prefer CSS Page Size")
API Documentation
Request Endpoint
POST /en/api/tools/html-to-pdf-precise
Request Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| htmlContent | textarea | Yes | - |
| cssContent | textarea | No | - |
| pageSize | select | No | - |
| landscape | checkbox | No | - |
| printBackground | checkbox | No | - |
| scale | number | No | - |
| marginTop | number | No | - |
| marginBottom | number | No | - |
| marginLeft | number | No | - |
| marginRight | number | No | - |
| headerTemplate | textarea | No | - |
| footerTemplate | textarea | No | - |
| mediaType | select | No | - |
| waitUntil | select | No | - |
| waitTime | number | No | - |
| preferCssPageSize | checkbox | No | - |
Response Format
{
"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)"
}
File:
File
AI MCP Documentation
Add this tool to your MCP server configuration:
{
"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://elysiatools.com/mcp/sse?toolId=html-to-pdf-precise",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}
You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.
If you encounter any issues, please contact us at [email protected]