Skip to content

导出 TikZ ​

Base URL: https://api.dajiaoai.com

接口地址: POST /api/render-tikz

接口接收一个符合大角工程文件(.algeo)数据协议的项目内容,渲染指定画板并返回导出文件地址与元数据。

尺寸单位

viewBound 使用画板逻辑坐标,scale 表示每个逻辑单位对应的像素数,返回结果中的 width 和 height 表示图片像素尺寸。工程内字号、线宽等视觉尺寸使用 px;如果你手头的规范使用 pt,请查看尺寸单位与换算。

鉴权方式见鉴权说明。

导出 2D TikZ/TeX,文件后缀为 .tex,MIME 类型为 text/plain。不接收 pixelRatio。

请求头 ​

请求头类型必填说明
Authorizationstring是Bearer API Key,格式为 Bearer <API_KEY>,无默认值。
Content-Typestring是固定为 application/json。
x-request-idstring否业务请求标识,省略时服务自动生成 UUID。

请求体 ​

字段类型必填说明
contentFileContentLatest是要渲染的完整项目内容,无默认值,格式见大角工程文件(.algeo)数据协议。
slideIndexnumber否目标画板序号,为从 1 开始的正整数,默认 1。
templateobject否渲染母版,省略时沿用目标画板现有样式。可在大角几何母版页面下载母版数据。
viewBound{
left: number;
right: number;
bottom: number;
top: number;
}
否逻辑视口边界,传入对象时四个属性均必填,且需为有限数值;要求 left < right 且 bottom < top。省略时使用目标画板保存的相机视口。
scalenumber否相机缩放比例(每逻辑单位对应的像素数),正数。省略时使用目标画板当前 camera.scale。

请求示例 ​

将主站或 SDK 导出的完整项目保存为 project.algeo;以下示例使用 jq 将项目内容放入请求的 content 字段。

bash
jq '{
  content: .,
  slideIndex: 1,
  viewBound: {
    left: -10,
    right: 10,
    bottom: -10,
    top: 10
  },
  scale: 50
}' project.algeo | \
  curl -X POST https://api.dajiaoai.com/api/render-tikz \
    -H "Authorization: Bearer djo_xxx" \
    -H "Content-Type: application/json" \
    -H "x-request-id: render-tikz-demo-001" \
    --data-binary @-

成功响应 ​

成功返回 200 OK:

json
{
  "success": true,
  "url": "https://dl.easeplay.vip/dajiao-open/dev/mcp/customer-id/session-id/4fa2bc.tex",
  "filename": "4fa2bc.tex",
  "objectKey": "dajiao-open/dev/mcp/customer-id/session-id/4fa2bc.tex",
  "slideIndex": 1,
  "viewBound": {
    "left": -10,
    "right": 10,
    "bottom": -10,
    "top": 10
  },
  "width": 768,
  "height": 768,
  "scale": 50,
  "mimeType": "text/plain",
  "size": 9631
}

失败响应 ​

见渲染接口失败响应。