Document Tools
Рендер HTML/CSS в PDF с точными колонтитулами и настройками печати
Вызовите этот инструмент из своего кода на трёх языках.
curl -X POST 'https://api.elysiatools.com/ru/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}'Отправьте POST-запрос с входными данными в JSON. Параметры типа «файл» требуют предварительной загрузки.
POST https://api.elysiatools.com/ru/api/tools/html-to-pdf-precise| Имя | Тип | Обязательный | Описание |
|---|---|---|---|
| htmlContent | textarea | Да | — |
| cssContent | textarea | Нет | — |
| pageSize | select | Нет | — |
| landscape | checkbox | Нет | — |
| printBackground | checkbox | Нет | — |
| scale | number | Нет | — |
| marginTop | number | Нет | — |
| marginBottom | number | Нет | — |
| marginLeft | number | Нет | — |
| marginRight | number | Нет | — |
| headerTemplate | textarea | Нет | — |
| footerTemplate | textarea | Нет | — |
| mediaType | select | Нет | — |
| waitUntil | select | Нет | — |
| waitTime | number | Нет | — |
| preferCssPageSize | checkbox | Нет | — |
Файловый результат
{
"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)"
}Добавьте этот инструмент на свой сервер Model Context Protocol, чтобы ИИ-агенты могли перечислять и вызывать его.
Добавьте этот блок в конфигурацию вашего MCP-клиента:
{
"mcpServers": {
"elysiatools-html-to-pdf-precise": {
"name": "html-to-pdf-precise",
"description": "Рендер HTML/CSS в PDF с точными колонтитулами и настройками печати",
"baseUrl": "https://api.elysiatools.com/mcp/sse?toolId=html-to-pdf-precise",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}После подключения к SSE-endpoint выведите список доступных инструментов:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}Вызовите инструмент по его id; аргументы формируются из его параметров:
{
"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
}
}
}Вопросы или проблемы? Свяжитесь с [email protected]