描述
- 支持返回元素或文本在Page的布局位置信息。主要应用于第三方对PDF/OFD等自动盖章或签名
接口
arrary GetLayoutMetrics(identity : object)identity参数
| 参数名 | 必填 | 类型 | 说明 | 备注 |
|---|---|---|---|---|
| mode | 否 | enum | 对象身份匹配模式 | E_IDENTITY_MATCH_MODE 当前接口使用场景 mode: 2 |
| ids | 否 | string array | 元素对象id数组 | |
| text | 否 | string array | 文本数组 |
arrary 返回值
- 注意:当入参匹配到多个对象/内容时,会把他们的页内布局信息都返回
| 类型 | 说明 | 备注 |
|---|---|---|
| identity | 对象标识 | 特别的,如果是文本位置,则 identity:{text:”张三”} 标识具体文本 |
| startLayout | 起始内容布局信息 | |
| endLayout | 结束内容布局信息 |
[
{
"identity": {
"id": "eleId1",
"uuid": "eleId1_1",
"sourceClass": "基本资料",
"sourceId": "姓名"
},
"startLayout": {
"x": "6.03",
"y": "5.35",
"width": "0.42",
"height": "0.42",
"lineIndex": 0,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
},
"endLayout": {
"x": "7.08",
"y": "5.35",
"width": "0.21",
"height": "0.42",
"lineIndex": 0,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
}
}
]字段含义
| 字段名 | 说明 | 备注 |
|---|---|---|
| x | 页内 左 偏移 | 相对于左上原点。单位:cm |
| y | 页内 上 偏移 | 相对于左上原点。单位:cm |
| width | 字符宽度 | 单位:cm |
| height | 字符高度 | 单位:cm |
| lineIndex | 行号 | 主要用于判断,起止内容是否换行 |
| pageIndex | 页号 | 主要用于判断,起止内容是否换页 |
| pageWidth | 页宽度 | 单位:cm |
| pageHeight | 页高度 | 单位:cm |
示例
入参
{
"mode": 2,
"ids": [
"eleId1",
"eleId2"
],
"texts": [
"张三",
"身份证"
]
}返回值
[
{
"identity": {
"id": "eleId1",
"uuid": "eleId1_1",
"sourceClass": "基本资料",
"sourceId": "姓名"
},
"startLayout": {
"x": "6.03",
"y": "5.35",
"width": "0.42",
"height": "0.42",
"lineIndex": 0,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
},
"endLayout": {
"x": "7.08",
"y": "5.35",
"width": "0.21",
"height": "0.42",
"lineIndex": 0,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
}
},
{
"identity": {
"id": "eleId1",
"uuid": "eleId1_2"
},
"startLayout": {
"x": "4.44",
"y": "12.53",
"width": "0.42",
"height": "0.42",
"lineIndex": 9,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
},
"endLayout": {
"x": "5.70",
"y": "12.53",
"width": "0.42",
"height": "0.42",
"lineIndex": 9,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
}
},
{
"identity": {
"id": "eleId2",
"uuid": "eleId2_3"
},
"startLayout": {
"x": "7.30",
"y": "6.15",
"width": "0.21",
"height": "0.42",
"lineIndex": 0,
"pageIndex": 1,
"pageWidth": "21.00",
"pageHeight": "29.70"
},
"endLayout": {
"x": "9.19",
"y": "6.15",
"width": "0.21",
"height": "0.42",
"lineIndex": 0,
"pageIndex": 1,
"pageWidth": "21.00",
"pageHeight": "29.70"
}
},
{
"identity": {
"text": "张三"
},
"startLayout": {
"x": "7.34",
"y": "10.22",
"width": "0.42",
"height": "0.42",
"lineIndex": 0,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
},
"endLayout": {
"x": "7.77",
"y": "10.22",
"width": "0.42",
"height": "0.42",
"lineIndex": 0,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
}
},
{
"identity": {
"text": "身份证"
},
"startLayout": {
"x": "8.42",
"y": "10.22",
"width": "0.42",
"height": "0.42",
"lineIndex": 0,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
},
"endLayout": {
"x": "6.03",
"y": "10.76",
"width": "0.42",
"height": "0.42",
"lineIndex": 1,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
}
},
{
"identity": {
"text": "张三"
},
"startLayout": {
"x": "3.77",
"y": "11.98",
"width": "0.42",
"height": "0.42",
"lineIndex": 8,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
},
"endLayout": {
"x": "4.19",
"y": "11.98",
"width": "0.42",
"height": "0.42",
"lineIndex": 8,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
}
},
{
"identity": {
"text": "身份证"
},
"startLayout": {
"x": "4.82",
"y": "11.98",
"width": "0.42",
"height": "0.42",
"lineIndex": 8,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
},
"endLayout": {
"x": "5.66",
"y": "11.98",
"width": "0.42",
"height": "0.42",
"lineIndex": 8,
"pageIndex": 0,
"pageWidth": "21.00",
"pageHeight": "29.70"
}
},
{
"identity": {
"text": "张三"
},
"startLayout": {
"x": "3.14",
"y": "7.35",
"width": "0.42",
"height": "0.42",
"lineIndex": 37,
"pageIndex": 1,
"pageWidth": "21.00",
"pageHeight": "29.70"
},
"endLayout": {
"x": "3.56",
"y": "7.35",
"width": "0.42",
"height": "0.42",
"lineIndex": 37,
"pageIndex": 1,
"pageWidth": "21.00",
"pageHeight": "29.70"
}
},
{
"identity": {
"text": "身份证"
},
"startLayout": {
"x": "4.19",
"y": "7.35",
"width": "0.42",
"height": "0.42",
"lineIndex": 37,
"pageIndex": 1,
"pageWidth": "21.00",
"pageHeight": "29.70"
},
"endLayout": {
"x": "5.03",
"y": "7.35",
"width": "0.42",
"height": "0.42",
"lineIndex": 37,
"pageIndex": 1,
"pageWidth": "21.00",
"pageHeight": "29.70"
}
}
]文档更新时间: 2026-11-03 14:56 作者:admin