Document Tools
Renderize HTML/CSS em PDF com cabeçalho, rodapé e ajustes precisos
Chame esta ferramenta a partir do seu código em três idiomas.
curl -X POST 'https://api.elysiatools.com/pt/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}'Envie uma requisição POST com suas entradas em JSON. Parâmetros do tipo arquivo exigem upload prévio.
POST https://api.elysiatools.com/pt/api/tools/html-to-pdf-precise| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| htmlContent | textarea | Sim | — |
| cssContent | textarea | Não | — |
| pageSize | select | Não | — |
| landscape | checkbox | Não | — |
| printBackground | checkbox | Não | — |
| scale | number | Não | — |
| marginTop | number | Não | — |
| marginBottom | number | Não | — |
| marginLeft | number | Não | — |
| marginRight | number | Não | — |
| headerTemplate | textarea | Não | — |
| footerTemplate | textarea | Não | — |
| mediaType | select | Não | — |
| waitUntil | select | Não | — |
| waitTime | number | Não | — |
| preferCssPageSize | checkbox | Não | — |
Resultado de arquivo
{
"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)"
}Adicione esta ferramenta ao seu servidor Model Context Protocol para que agentes de IA possam listá-la e chamá-la.
Adicione este bloco à configuração do seu cliente MCP:
{
"mcpServers": {
"elysiatools-html-to-pdf-precise": {
"name": "html-to-pdf-precise",
"description": "Renderize HTML/CSS em PDF com cabeçalho, rodapé e ajustes precisos",
"baseUrl": "https://api.elysiatools.com/mcp/sse?toolId=html-to-pdf-precise",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}Após conectar ao endpoint SSE, liste as ferramentas expostas:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}Invoque a ferramenta pelo seu id; os argumentos são construídos a partir de seus 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
}
}
}Dúvidas ou problemas? Contate [email protected]