Media
将 SVG 矢量图形转换为 PDF 文档,用于打印和共享
用三种语言从你的代码中调用此工具。
# 1) Upload each file first → returns { filePath }
curl -X POST 'https://api.elysiatools.com/upload/svg-to-pdf' \
-F 'file=@/path/to/svgFile.ext'
# 2) Call the tool with the returned filePath values
curl -X POST 'https://api.elysiatools.com/zh/api/tools/svg-to-pdf' \
-F 'svgFile=/path/to/file.ext' \
-F 'pageSize=A4' \
-F 'fit=fit' \
-F 'margin=20' \
-F 'density=150' \
-F 'title=输入可选的PDF标题...' \
-F 'backgroundColor=white'以 JSON 形式 POST 提交输入参数。文件类型参数需先单独上传。
POST https://api.elysiatools.com/zh/api/tools/svg-to-pdf| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| svgFile | file需先上传 | 是 | 支持 SVG (Scalable Vector Graphics) 矢量图形格式 |
| pageSize | select | 否 | 选择PDF页面大小 |
| fit | select | 否 | SVG在PDF页面中的适配方式 |
| margin | number | 否 | 页面边距,单位毫米 |
| density | range | 否 | 渲染 DPI(72-300),数值越高质量越好 |
将此工具加入你的 Model Context Protocol 服务,让 AI 智能体可以列出并调用它。
将以下内容加入你的 MCP 客户端配置:
{
"mcpServers": {
"elysiatools-svg-to-pdf": {
"name": "svg-to-pdf",
"description": "将 SVG 矢量图形转换为 PDF 文档,用于打印和共享",
"baseUrl": "https://api.elysiatools.com/mcp/sse?toolId=svg-to-pdf",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}连接到 SSE 端点后,列出已开放的工具:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}通过工具 id 调用,参数由其参数表构建:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "svg-to-pdf",
"arguments": {
"svgFile": "https://example.com/file.ext",
"pageSize": "A4",
"fit": "fit",
"margin": 20,
"density": 150,
"title": "输入可选的PDF标题...",
"backgroundColor": "white"
}
}
}| title |
| text |
| 否 |
| 将显示在PDF顶部的可选标题 |
| backgroundColor | select | 否 | Background color for the PDF |
文件结果
{
"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)"
}有问题或反馈?请联系 [email protected]