# example of looking up the corresponding page
annotation = task.response.annotations[0]
document_page = task.document_pages[annotation.page]
# example of normalizing the location in the page
if annotation.location.type == "box":
left = annotation.location.left / document_page.width
top = annotation.location.top / document_page.height
width = annotation.location.width / document_page.width
height = annotation.location.height / document_page.height
elif annotation.location.type == "polygon":
vertices = [
{x: v.x / document_page.width, y: v.y / document_page.height}
for v in annotation.location.vertices
]
// example of looking up the corresponding page
const annotation = task.response.annotations[0];
const documentPage = task.document_pages[annotation.page];
// example of normalizing the location in the page
if (annotation.location.type === 'box') {
const left = annotation.location.left / documentPage.width;
const top = annotation.location.top / documentPage.height;
const width = annotation.location.width / documentPage.width;
const height = annotation.location.height / documentPage.height;
} else if (annotation.location.type === 'polygon') {
const vertices = annotation.location.vertices.map(v => ({
x: v.x / documentPage.width,
y: v.y / documentPage.height,
}));
}
Document Transcription and Document Model tasks include document pages in the JSON callback. For multiple page file types including PDF and TIFF attachments there will be multiple document pages in the callback, one per page. For single page file types including JPEG and PNG there will be a single corresponding page in the callback.
Parameter | Type | Description |
---|---|---|
document_pages | object array | A list of Document Page objects. See below. |
Document pages are provided in the callback in the same order as the task attachments. The index of the object in the array corresponds to the page
field in annotations. The width and heigh correspond to the dimensions in the annotation location
field.
Document Page
Parameter | Type | Description |
---|---|---|
width | number | The width of the converted page in pixels. |
height | number | The height of the converted page in pixels. |
url | string | The API endpoint to download the JPEG file. |
In order to debug the model or labeling response, download the image, group the annotations per page, and display the annotations at the location
to see where information was extracted from. Scale's labeling tool and dashboard work the same way.