分类

PDF代码片段查看器

为代码块添加背景框、等宽字体并支持跳转到Git仓库

生成便于评审的代码片段 PDF,每段带仓库可点击链接。

示例结果

2 个示例

浅色主题多片段预览

渲染两个TypeScript片段并附可点击GitHub链接

code-snippet-viewer-example1.pdf 查看文件
查看输入参数
{ "snippetsJson": "[{\"filePath\":\"src/index.ts\",\"language\":\"ts\",\"startLine\":1,\"endLine\":8,\"code\":\"import { Elysia } from 'elysia'\\n\\nconst app = new Elysia()\\n\\napp.get('/', () => 'ok')\\n\\nexport default app\"},{\"filePath\":\"src/tools/2026-02-13/pdf-link-annotator.ts\",\"language\":\"ts\",\"startLine\":30,\"endLine\":52,\"code\":\"function addExternalLink(pdf, page, x, y, w, h, url) {\\n const annot = pdf.context.obj({\\n Type: 'Annot',\\n Subtype: 'Link',\\n })\\n // ...\\n}\"}]", "repoBaseUrl": "https://github.com/example/repo", "branch": "main", "pageSize": "A4", "landscape": false, "theme": "light" }

深色主题横版评审

单个代码片段,Letter横版深色主题展示

code-snippet-viewer-example2.pdf 查看文件
查看输入参数
{ "snippetsJson": "[{\"filePath\":\"src/tool-manager.ts\",\"language\":\"ts\",\"startLine\":55,\"endLine\":92,\"code\":\"export class ToolManager {\\n private tools = new Map()\\n\\n registerTool(tool) {\\n this.tools.set(tool.id, tool)\\n }\\n\\n getTool(id) {\\n return this.tools.get(id)\\n }\\n}\"}]", "repoBaseUrl": "https://gitlab.com/example/platform", "branch": "develop", "pageSize": "Letter", "landscape": true, "theme": "dark" }

API 文档

请求端点

POST /zh/api/tools/pdf-code-snippet-viewer

请求参数

参数名 类型 必填 描述
snippetsJson textarea -
repoBaseUrl text -
branch text -
pageSize select -
landscape checkbox -
theme select -

响应格式

{
  "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)"
}
文件: 文件

AI MCP 文档

将此工具添加到您的 MCP 服务器配置中:

{
  "mcpServers": {
    "elysiatools-pdf-code-snippet-viewer": {
      "name": "pdf-code-snippet-viewer",
      "description": "为代码块添加背景框、等宽字体并支持跳转到Git仓库",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=pdf-code-snippet-viewer",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

你可以串联多个工具,比如:`https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`,最多20个。

如果遇见问题,请联系我们:[email protected]