Skip to content

页级结构说明

result.pages 按页返回解析结果。每一页对象包含页级元数据、结构化块列表和轻量级内容列表。此外,result.detail 还提供一个跨页的扁平化段落级视角。

页对象字段

单页对象包含以下字段:

字段类型说明
page_idint页码,从 1 开始
anglefloat页面旋转角度(校正后)
heightint页面的像素高度
widthint页面的像素宽度
image_idstring原始图片标识(通常为空)
durationsfloat该页的处理耗时(秒)
statusstring处理状态,如 Success
structuredarray结构化块列表,适合精细化渲染与定位
contentarray轻量级内容列表,适合快速获取文本

structured — 结构化块

适合做精细化渲染、定位高亮和内容重组。每个块对象包含:

字段类型说明
idint块序号
typestring块类型,如 doc_titleparagraph_titletexttableimage
textstring当前块提取出的文本
posfloat[]在原页中的四边形坐标 [x1,y1, x2,y2, x3,y3, x4,y4],分别对应左上、右上、右下、左下四个角
outline_levelint标题等级(-1 表示非标题)
contentint[]引用的文本块 ID 列表,可与 content 数组关联
json
{
  "id": 0,
  "type": "doc_title",
  "text": "# Sample PDF",
  "pos": [141, 154, 509, 154, 509, 220, 141, 220],
  "outline_level": -1,
  "content": [0]
}

常见块类型:

类型说明
doc_title文档标题
paragraph_title段落标题
text正文文本
table表格
image图片
figure图表
header / footer页眉 / 页脚
footnote脚注
formula公式

content — 轻量级内容

更适合做快速消费,直接拼接成页级文本或生成搜索索引。每个内容块包含:

字段类型说明
idint内容块 ID,与 structured[].content 关联
typestring块类型
textstring文本内容
posfloat[]四边形坐标
scorefloat识别置信度
anglefloat文本角度
json
{
  "id": 0,
  "type": "doc_title",
  "text": "# Sample PDF",
  "pos": [141, 154, 509, 154, 509, 220, 141, 220],
  "score": 0.5958,
  "angle": 0
}

result.detail — 跨页段落级视角

result.detail 将文档中所有段落按阅读顺序排列为一个扁平数组,无需逐页遍历。每条记录包含:

字段类型说明
paragraph_idint段落序号
page_idint所属页码
typestring固定为 paragraph
sub_typestring段落子类型,如 doc_titleparagraph_titletexttable
textstring段落文本
positionfloat[]在原页中的四边形坐标
outline_levelint标题等级
tagsstring[]自定义标签
json
{
  "paragraph_id": 1,
  "page_id": 1,
  "type": "paragraph",
  "sub_type": "doc_title",
  "text": "# Sample PDF",
  "position": [141, 154, 509, 154, 509, 220, 141, 220],
  "outline_level": -1,
  "tags": []
}

典型使用方式

  • 做页面高亮回显:读取 structured[].poscontent[].pos
  • 做块级过滤:根据 structured[].type 筛选
  • 做全文阅读:优先使用 result.markdown 或遍历 content
  • 做结构化二次处理:遍历 result.pages,逐页消费 structured
  • 做跨页段落处理:直接遍历 result.detail,无需手动合并各页

结合其他页面阅读