Document Tools
Renderiza HTML/CSS a PDF con encabezados, pies y ajustes de impresión precisos
Llama a esta herramienta desde tu código en tres lenguajes.
curl -X POST 'https://api.elysiatools.com/es/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}'Envía una petición POST con tus entradas en JSON. Los parámetros de tipo archivo requieren una subida previa.
POST https://api.elysiatools.com/es/api/tools/html-to-pdf-precise| Nombre | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| htmlContent | textarea | Sí | — |
| 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 | — |
Resultado de archivo
{
"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)"
}Añade esta herramienta a tu servidor Model Context Protocol para que los agentes de IA puedan listarla y llamarla.
Añade este bloque a la configuración de tu cliente MCP:
{
"mcpServers": {
"elysiatools-html-to-pdf-precise": {
"name": "html-to-pdf-precise",
"description": "Renderiza HTML/CSS a PDF con encabezados, pies y ajustes de impresión precisos",
"baseUrl": "https://api.elysiatools.com/mcp/sse?toolId=html-to-pdf-precise",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}Tras conectar al endpoint SSE, lista las herramientas expuestas:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}Invoca la herramienta por su id; los argumentos se construyen a partir de sus parámetros:
{
"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
}
}
}¿Dudas o problemas? Contacta con [email protected]