页级结构说明
result.pages 按页返回解析结果。每一页对象包含页级元数据、结构化块列表和轻量级内容列表。此外,result.detail 还提供一个跨页的扁平化段落级视角。
页对象字段
单页对象包含以下字段:
| 字段 | 类型 | 说明 |
|---|---|---|
page_id | int | 页码,从 1 开始 |
angle | float | 页面旋转角度(校正后) |
height | int | 页面的像素高度 |
width | int | 页面的像素宽度 |
image_id | string | 原始图片标识(通常为空) |
durations | float | 该页的处理耗时(秒) |
status | string | 处理状态,如 Success |
structured | array | 结构化块列表,适合精细化渲染与定位 |
content | array | 轻量级内容列表,适合快速获取文本 |
structured — 结构化块
适合做精细化渲染、定位高亮和内容重组。每个块对象包含:
| 字段 | 类型 | 说明 |
|---|---|---|
id | int | 块序号 |
type | string | 块类型,如 doc_title、paragraph_title、text、table、image 等 |
text | string | 当前块提取出的文本 |
pos | float[] | 在原页中的四边形坐标 [x1,y1, x2,y2, x3,y3, x4,y4],分别对应左上、右上、右下、左下四个角 |
outline_level | int | 标题等级(-1 表示非标题) |
content | int[] | 引用的文本块 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 — 轻量级内容
更适合做快速消费,直接拼接成页级文本或生成搜索索引。每个内容块包含:
| 字段 | 类型 | 说明 |
|---|---|---|
id | int | 内容块 ID,与 structured[].content 关联 |
type | string | 块类型 |
text | string | 文本内容 |
pos | float[] | 四边形坐标 |
score | float | 识别置信度 |
angle | float | 文本角度 |
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_id | int | 段落序号 |
page_id | int | 所属页码 |
type | string | 固定为 paragraph |
sub_type | string | 段落子类型,如 doc_title、paragraph_title、text、table 等 |
text | string | 段落文本 |
position | float[] | 在原页中的四边形坐标 |
outline_level | int | 标题等级 |
tags | string[] | 自定义标签 |
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[].pos或content[].pos - 做块级过滤:根据
structured[].type筛选 - 做全文阅读:优先使用
result.markdown或遍历content - 做结构化二次处理:遍历
result.pages,逐页消费structured - 做跨页段落处理:直接遍历
result.detail,无需手动合并各页