Document

Document represents the canonical document resource in Document AI. It is an interchange format that provides insights into documents and allows for collaboration between users and Document AI to iterate and optimize for quality.

JSON representation
{
  "mimeType": string,
  "text": string,
  "textStyles": [
    {
      object (Style)
    }
  ],
  "pages": [
    {
      object (Page)
    }
  ],
  "entities": [
    {
      object (Entity)
    }
  ],
  "entityRelations": [
    {
      object (EntityRelation)
    }
  ],
  "textChanges": [
    {
      object (TextChange)
    }
  ],
  "shardInfo": {
    object (ShardInfo)
  },
  "error": {
    object (Status)
  },
  "revisions": [
    {
      object (Revision)
    }
  ],
  "documentLayout": {
    object (DocumentLayout)
  },
  "chunkedDocument": {
    object (ChunkedDocument)
  },

  // Union field source can be only one of the following:
  "uri": string,
  "content": string
  // End of list of possible types for union field source.
}
Fields
mimeType

string

An IANA published media type (MIME type).

text

string

Optional. UTF-8 encoded text in reading order from the document.

textStyles[]
(deprecated)

object (Style)

Styles for the Document.text.

pages[]

object (Page)

Visual page layout for the Document.

entities[]

object (Entity)

A list of entities detected on Document.text. For document shards, entities in this list may cross shard boundaries.

entityRelations[]

object (EntityRelation)

Placeholder. Relationship among Document.entities.

textChanges[]

object (TextChange)

Placeholder. A list of text corrections made to Document.text. This is usually used for annotating corrections to OCR mistakes. Text changes for a given revision may not overlap with each other.

shardInfo

object (ShardInfo)

Information about the sharding if this document is sharded part of a larger document. If the document is not sharded, this message is not specified.

error

object (Status)

Any error that occurred while processing this document.

revisions[]

object (Revision)

Placeholder. Revision history of this document.

documentLayout

object (DocumentLayout)

Parsed layout of the document.

chunkedDocument

object (ChunkedDocument)

Document chunked based on chunking config.

Union field source. Original source document from the user. source can be only one of the following:
uri

string

Optional. Currently supports Google Cloud Storage URI of the form gs://bucket_name/object_name. Object versioning is not supported. For more information, refer to Google Cloud Storage Request URIs.

content

string (bytes format)

Optional. Inline document content, represented as a stream of bytes. Note: As with all bytes fields, protobuffers use a pure binary representation, whereas JSON representations use base64.

A base64-encoded string.

Style

Annotation for common text style attributes. This adheres to CSS conventions as much as possible.

JSON representation
{
  "textAnchor": {
    object (TextAnchor)
  },
  "color": {
    object (Color)
  },
  "backgroundColor": {
    object (Color)
  },
  "fontWeight": string,
  "textStyle": string,
  "textDecoration": string,
  "fontSize": {
    object (FontSize)
  },
  "fontFamily": string
}
Fields
textAnchor

object (TextAnchor)

Text anchor indexing into the Document.text.

color

object (Color)

Text color.

backgroundColor

object (Color)

Text background color.

fontWeight

string

Font weight. Possible values are normal, bold, bolder, and lighter.

textStyle

string

Text style. Possible values are normal, italic, and oblique.

textDecoration

string

Text decoration. Follows CSS standard.

fontSize

object (FontSize)

Font size.

fontFamily

string

Font family such as Arial, Times New Roman. https://www.w3schools.com/cssref/pr_font_font-family.asp

TextAnchor

Text reference indexing into the Document.text.

JSON representation
{
  "textSegments": [
    {
      object (TextSegment)
    }
  ],
  "content": string
}
Fields
textSegments[]

object (TextSegment)

The text segments from the Document.text.

content

string

Contains the content of the text span so that users do not have to look it up in the textSegments. It is always populated for formFields.

TextSegment

A text segment in the Document.text. The indices may be out of bounds which indicate that the text extends into another document shard for large sharded documents. See ShardInfo.text_offset

JSON representation
{
  "startIndex": string,
  "endIndex": string
}
Fields
startIndex

string (int64 format)

TextSegment start UTF-8 char index in the Document.text.

endIndex

string (int64 format)

TextSegment half open end UTF-8 char index in the Document.text.

FontSize

Font size with unit.

JSON representation
{
  "size": number,
  "unit": string
}
Fields
size

number

Font size for the text.

unit

string

Unit for the font size. Follows CSS naming (such as in, px, and pt).

Page

A page in a Document.

JSON representation
{
  "pageNumber": integer,
  "image": {
    object (Image)
  },
  "transforms": [
    {
      object (Matrix)
    }
  ],
  "dimension": {
    object (Dimension)
  },
  "layout": {
    object (Layout)
  },
  "detectedLanguages": [
    {
      object (DetectedLanguage)
    }
  ],
  "blocks": [
    {
      object (Block)
    }
  ],
  "paragraphs": [
    {
      object (Paragraph)
    }
  ],
  "lines": [
    {
      object (Line)
    }
  ],
  "tokens": [
    {
      object (Token)
    }
  ],
  "visualElements": [
    {
      object (VisualElement)
    }
  ],
  "tables": [
    {
      object (Table)
    }
  ],
  "formFields": [
    {
      object (FormField)
    }
  ],
  "symbols": [
    {
      object (Symbol)
    }
  ],
  "detectedBarcodes": [
    {
      object (DetectedBarcode)
    }
  ],
  "imageQualityScores": {
    object (ImageQualityScores)
  },
  "provenance": {
    object (Provenance)
  }
}
Fields
pageNumber

integer

1-based index for current Page in a parent Document. Useful when a page is taken out of a Document for individual processing.

image

object (Image)

Rendered image for this page. This image is preprocessed to remove any skew, rotation, and distortions such that the annotation bounding boxes can be upright and axis-aligned.

transforms[]

object (Matrix)

Transformation matrices that were applied to the original document image to produce Page.image.

dimension

object (Dimension)

Physical dimension of the page.

layout

object (Layout)

Layout for the page.

detectedLanguages[]

object (DetectedLanguage)

A list of detected languages together with confidence.

blocks[]

object (Block)

A list of visually detected text blocks on the page. A block has a set of lines (collected into paragraphs) that have a common line-spacing and orientation.

paragraphs[]

object (Paragraph)

A list of visually detected text paragraphs on the page. A collection of lines that a human would perceive as a paragraph.

lines[]

object (Line)

A list of visually detected text lines on the page. A collection of tokens that a human would perceive as a line.

tokens[]

object (Token)

A list of visually detected tokens on the page.

visualElements[]

object (VisualElement)

A list of detected non-text visual elements e.g. checkbox, signature etc. on the page.

tables[]

object (Table)

A list of visually detected tables on the page.

formFields[]

object (FormField)

A list of visually detected form fields on the page.

symbols[]

object (Symbol)

A list of visually detected symbols on the page.

detectedBarcodes[]

object (DetectedBarcode)

A list of detected barcodes.

imageQualityScores

object (ImageQualityScores)

Image quality scores.

provenance
(deprecated)

object (Provenance)

The history of this page.

Image

Rendered image contents for this page.

JSON representation
{
  "content": string,
  "mimeType": string,
  "width": integer,
  "height": integer
}
Fields
content

string (bytes format)

Raw byte content of the image.

A base64-encoded string.

mimeType

string

Encoding media type (MIME type) for the image.

width

integer

Width of the image in pixels.

height

integer

Height of the image in pixels.

Matrix

Representation for transformation matrix, intended to be compatible and used with OpenCV format for image manipulation.

JSON representation
{
  "rows": integer,
  "cols": integer,
  "type": integer,
  "data": string
}
Fields
rows

integer

Number of rows in the matrix.

cols

integer

Number of columns in the matrix.

type

integer

This encodes information about what data type the matrix uses. For example, 0 (CV_8U) is an unsigned 8-bit image. For the full list of OpenCV primitive data types, please refer to https://docs.opencv.org/4.3.0/d1/d1b/group__core__hal__interface.html

data

string (bytes format)

The matrix data.

A base64-encoded string.

Dimension

Dimension for the page.

JSON representation
{
  "width": number,
  "height": number,
  "unit": string
}
Fields
width

number

Page width.

height

number

Page height.

unit

string

Dimension unit.

Layout

Visual element describing a layout unit on a page.

JSON representation
{
  "textAnchor": {
    object (TextAnchor)
  },
  "confidence": number,
  "boundingPoly": {
    object (BoundingPoly)
  },
  "orientation": enum (Orientation)
}
Fields
textAnchor

object (TextAnchor)

Text anchor indexing into the Document.text.

confidence

number

Confidence of the current Layout within context of the object this layout is for. e.g. confidence can be for a single token, a table, a visual element, etc. depending on context. Range [0, 1].

boundingPoly

object (BoundingPoly)

The bounding polygon for the Layout.

orientation

enum (Orientation)

Detected orientation for the Layout.

BoundingPoly

A bounding polygon for the detected image annotation.

JSON representation
{
  "vertices": [
    {
      object (Vertex)
    }
  ],
  "normalizedVertices": [
    {
      object (NormalizedVertex)
    }
  ]
}
Fields
vertices[]

object (Vertex)

The bounding polygon vertices.

normalizedVertices[]

object (NormalizedVertex)

The bounding polygon normalized vertices.

Vertex

A vertex represents a 2D point in the image. NOTE: the vertex coordinates are in the same scale as the original image.

JSON representation
{
  "x": integer,
  "y": integer
}
Fields
x

integer

X coordinate.

y

integer

Y coordinate (starts from the top of the image).

NormalizedVertex

A vertex represents a 2D point in the image. NOTE: the normalized vertex coordinates are relative to the original image and range from 0 to 1.

JSON representation
{
  "x": number,
  "y": number
}
Fields
x

number

X coordinate.

y

number

Y coordinate (starts from the top of the image).

Orientation

Detected human reading orientation.

Enums
ORIENTATION_UNSPECIFIED Unspecified orientation.
PAGE_UP Orientation is aligned with page up.
PAGE_RIGHT Orientation is aligned with page right. Turn the head 90 degrees clockwise from upright to read.
PAGE_DOWN Orientation is aligned with page down. Turn the head 180 degrees from upright to read.
PAGE_LEFT Orientation is aligned with page left. Turn the head 90 degrees counterclockwise from upright to read.

DetectedLanguage

Detected language for a structural component.

JSON representation
{
  "languageCode": string,
  "confidence": number
}
Fields
languageCode

string

The BCP-47 language code, such as en-US or sr-Latn.

confidence

number

Confidence of detected language. Range [0, 1].

Block

A block has a set of lines (collected into paragraphs) that have a common line-spacing and orientation.

JSON representation
{
  "layout": {
    object (Layout)
  },
  "detectedLanguages": [
    {
      object (DetectedLanguage)
    }
  ],
  "provenance": {
    object (Provenance)
  }
}
Fields
layout

object (Layout)

Layout for Block.

detectedLanguages[]

object (DetectedLanguage)

A list of detected languages together with confidence.

provenance
(deprecated)

object (Provenance)

The history of this annotation.

Provenance

Structure to identify provenance relationships between annotations in different revisions.

JSON representation
{
  "revision": integer,
  "id": integer,
  "parents": [
    {
      object (Parent)
    }
  ],
  "type": enum (OperationType)
}
Fields
revision
(deprecated)

integer

The index of the revision that produced this element.

id
(deprecated)

integer

The Id of this operation. Needs to be unique within the scope of the revision.

parents[]

object (Parent)

References to the original elements that are replaced.

type

enum (OperationType)

The type of provenance operation.

Parent

The parent element the current element is based on. Used for referencing/aligning, removal and replacement operations.

JSON representation
{
  "revision": integer,
  "index": integer,
  "id": integer
}
Fields
revision

integer

The index of the index into current revision's parentIds list.

index

integer

The index of the parent item in the corresponding item list (eg. list of entities, properties within entities, etc.) in the parent revision.

id
(deprecated)

integer

The id of the parent provenance.

OperationType

If a processor or agent does an explicit operation on existing elements.

Enums
OPERATION_TYPE_UNSPECIFIED Operation type unspecified. If no operation is specified a provenance entry is simply used to match against a parent.
ADD Add an element.
REMOVE Remove an element identified by parent.
UPDATE Updates any fields within the given provenance scope of the message. It overwrites the fields rather than replacing them. Use this when you want to update a field value of an entity without also updating all the child properties.
REPLACE Currently unused. Replace an element identified by parent.
EVAL_REQUESTED

Deprecated. Request human review for the element identified by parent.

EVAL_APPROVED

Deprecated. Element is reviewed and approved at human review, confidence will be set to 1.0.

EVAL_SKIPPED

Deprecated. Element is skipped in the validation process.

Paragraph

A collection of lines that a human would perceive as a paragraph.

JSON representation
{
  "layout": {
    object (Layout)
  },
  "detectedLanguages": [
    {
      object (DetectedLanguage)
    }
  ],
  "provenance": {
    object (Provenance)
  }
}
Fields
layout

object (Layout)

Layout for Paragraph.

detectedLanguages[]

object (DetectedLanguage)

A list of detected languages together with confidence.

provenance
(deprecated)

object (Provenance)

The history of this annotation.

Line

A collection of tokens that a human would perceive as a line. Does not cross column boundaries, can be horizontal, vertical, etc.

JSON representation
{
  "layout": {
    object (Layout)
  },
  "detectedLanguages": [
    {
      object (DetectedLanguage)
    }
  ],
  "provenance": {
    object (Provenance)
  }
}
Fields
layout

object (Layout)

Layout for Line.

detectedLanguages[]

object (DetectedLanguage)

A list of detected languages together with confidence.

provenance
(deprecated)

object (Provenance)

The history of this annotation.

Token

A detected token.

JSON representation
{
  "layout": {
    object (Layout)
  },
  "detectedBreak": {
    object (DetectedBreak)
  },
  "detectedLanguages": [
    {
      object (DetectedLanguage)
    }
  ],
  "provenance": {
    object (Provenance)
  },
  "styleInfo": {
    object (StyleInfo)
  }
}
Fields
layout

object (Layout)

Layout for Token.

detectedBreak

object (DetectedBreak)

Detected break at the end of a Token.

detectedLanguages[]

object (DetectedLanguage)

A list of detected languages together with confidence.

provenance
(deprecated)

object (Provenance)

The history of this annotation.

styleInfo

object (StyleInfo)

Text style attributes.

DetectedBreak

Detected break at the end of a Token.

JSON representation
{
  "type": enum (Type)
}
Fields
type

enum (Type)

Detected break type.

Type

Enum to denote the type of break found.

Enums
TYPE_UNSPECIFIED Unspecified break type.
SPACE A single whitespace.
WIDE_SPACE A wider whitespace.
HYPHEN A hyphen that indicates that a token has been split across lines.

StyleInfo

Font and other text style attributes.

JSON representation
{
  "fontSize": integer,
  "pixelFontSize": number,
  "letterSpacing": number,
  "fontType": string,
  "bold": boolean,
  "italic": boolean,
  "underlined": boolean,
  "strikeout": boolean,
  "subscript": boolean,
  "superscript": boolean,
  "smallcaps": boolean,
  "fontWeight": integer,
  "handwritten": boolean,
  "textColor": {
    object (Color)
  },
  "backgroundColor": {
    object (Color)
  }
}
Fields
fontSize

integer

Font size in points (1 point is ¹⁄₇₂ inches).

pixelFontSize

number

Font size in pixels, equal to unrounded fontSize * resolution ÷ 72.0.

letterSpacing

number

Letter spacing in points.

fontType

string

Name or style of the font.

bold

boolean

Whether the text is bold (equivalent to fontWeight is at least 700).

italic

boolean

Whether the text is italic.

underlined

boolean

Whether the text is underlined.

strikeout

boolean

Whether the text is strikethrough. This feature is not supported yet.

subscript

boolean

Whether the text is a subscript. This feature is not supported yet.

superscript

boolean

Whether the text is a superscript. This feature is not supported yet.

smallcaps

boolean

Whether the text is in small caps. This feature is not supported yet.

fontWeight

integer

TrueType weight on a scale 100 (thin) to 1000 (ultra-heavy). Normal is 400, bold is 700.

handwritten

boolean

Whether the text is handwritten.

textColor

object (Color)

Color of the text.

backgroundColor

object (Color)

Color of the background.

VisualElement

Detected non-text visual elements e.g. checkbox, signature etc. on the page.

JSON representation
{
  "layout": {
    object (Layout)
  },
  "type": string,
  "detectedLanguages": [
    {
      object (DetectedLanguage)
    }
  ]
}
Fields
layout

object (Layout)

Layout for VisualElement.

type

string

Type of the VisualElement.

detectedLanguages[]

object (DetectedLanguage)

A list of detected languages together with confidence.

Table

A table representation similar to HTML table structure.

JSON representation
{
  "layout": {
    object (Layout)
  },
  "headerRows": [
    {
      object (TableRow)
    }
  ],
  "bodyRows": [
    {
      object (TableRow)
    }
  ],
  "detectedLanguages": [
    {
      object (DetectedLanguage)
    }
  ],
  "provenance": {
    object (Provenance)
  }
}
Fields
layout

object (Layout)

Layout for Table.

headerRows[]

object (TableRow)

Header rows of the table.

bodyRows[]

object (TableRow)

Body rows of the table.

detectedLanguages[]

object (DetectedLanguage)

A list of detected languages together with confidence.

provenance
(deprecated)

object (Provenance)

The history of this table.

TableRow

A row of table cells.

JSON representation
{
  "cells": [
    {
      object (TableCell)
    }
  ]
}
Fields
cells[]

object (TableCell)

Cells that make up this row.

TableCell

A cell representation inside the table.

JSON representation
{
  "layout": {
    object (Layout)
  },
  "rowSpan": integer,
  "colSpan": integer,
  "detectedLanguages": [
    {
      object (DetectedLanguage)
    }
  ]
}
Fields
layout

object (Layout)

Layout for TableCell.

rowSpan

integer

How many rows this cell spans.

colSpan

integer

How many columns this cell spans.

detectedLanguages[]

object (DetectedLanguage)

A list of detected languages together with confidence.

FormField

A form field detected on the page.

JSON representation
{
  "fieldName": {
    object (Layout)
  },
  "fieldValue": {
    object (Layout)
  },
  "nameDetectedLanguages": [
    {
      object (DetectedLanguage)
    }
  ],
  "valueDetectedLanguages": [
    {
      object (DetectedLanguage)
    }
  ],
  "valueType": string,
  "correctedKeyText": string,
  "correctedValueText": string,
  "provenance": {
    object (Provenance)
  }
}
Fields
fieldName

object (Layout)

Layout for the FormField name. e.g. Address, Email, Grand total, Phone number, etc.

fieldValue

object (Layout)

Layout for the FormField value.

nameDetectedLanguages[]

object (DetectedLanguage)

A list of detected languages for name together with confidence.

valueDetectedLanguages[]

object (DetectedLanguage)

A list of detected languages for value together with confidence.

valueType

string

If the value is non-textual, this field represents the type. Current valid values are:

  • blank (this indicates the fieldValue is normal text)
  • unfilled_checkbox
  • filled_checkbox
correctedKeyText

string

Created for Labeling UI to export key text. If corrections were made to the text identified by the fieldName.text_anchor, this field will contain the correction.

correctedValueText

string

Created for Labeling UI to export value text. If corrections were made to the text identified by the fieldValue.text_anchor, this field will contain the correction.

provenance

object (Provenance)

The history of this annotation.

Symbol

A detected symbol.

JSON representation
{
  "layout": {
    object (Layout)
  },
  "detectedLanguages": [
    {
      object (DetectedLanguage)
    }
  ]
}
Fields
layout

object (Layout)

Layout for Symbol.

detectedLanguages[]

object (DetectedLanguage)

A list of detected languages together with confidence.

DetectedBarcode

A detected barcode.

JSON representation
{
  "layout": {
    object (Layout)
  },
  "barcode": {
    object (Barcode)
  }
}
Fields
layout

object (Layout)

Layout for DetectedBarcode.

barcode

object (Barcode)

Detailed barcode information of the DetectedBarcode.

Barcode

Encodes the detailed information of a barcode.

JSON representation
{
  "format": string,
  "valueFormat": string,
  "rawValue": string
}
Fields
format

string

Format of a barcode. The supported formats are:

  • CODE_128: Code 128 type.
  • CODE_39: Code 39 type.
  • CODE_93: Code 93 type.
  • CODABAR: Codabar type.
  • DATA_MATRIX: 2D Data Matrix type.
  • ITF: ITF type.
  • EAN_13: EAN-13 type.
  • EAN_8: EAN-8 type.
  • QR_CODE: 2D QR code type.
  • UPC_A: UPC-A type.
  • UPC_E: UPC-E type.
  • PDF417: PDF417 type.
  • AZTEC: 2D Aztec code type.
  • DATABAR: GS1 DataBar code type.
valueFormat

string

Value format describes the format of the value that a barcode encodes. The supported formats are:

  • CONTACT_INFO: Contact information.
  • EMAIL: Email address.
  • ISBN: ISBN identifier.
  • PHONE: Phone number.
  • PRODUCT: Product.
  • SMS: SMS message.
  • TEXT: Text string.
  • URL: URL address.
  • WIFI: Wifi information.
  • GEO: Geo-localization.
  • CALENDAR_EVENT: Calendar event.
  • DRIVER_LICENSE: Driver's license.
rawValue

string

Raw value encoded in the barcode. For example: 'MEBKM:TITLE:Google;URL:https://www.google.com;;'.

ImageQualityScores

Image quality scores for the page image.

JSON representation
{
  "qualityScore": number,
  "detectedDefects": [
    {
      object (DetectedDefect)
    }
  ]
}
Fields
qualityScore

number

The overall quality score. Range [0, 1] where 1 is perfect quality.

detectedDefects[]

object (DetectedDefect)

A list of detected defects.

DetectedDefect

Image Quality Defects

JSON representation
{
  "type": string,
  "confidence": number
}
Fields
type

string

Name of the defect type. Supported values are:

  • quality/defect_blurry
  • quality/defect_noisy
  • quality/defect_dark
  • quality/defect_faint
  • quality/defect_text_too_small
  • quality/defect_document_cutoff
  • quality/defect_text_cutoff
  • quality/defect_glare
confidence

number

Confidence of detected defect. Range [0, 1] where 1 indicates strong confidence that the defect exists.

Entity

An entity that could be a phrase in the text or a property that belongs to the document. It is a known entity type, such as a person, an organization, or location.

JSON representation
{
  "textAnchor": {
    object (TextAnchor)
  },
  "type": string,
  "mentionText": string,
  "mentionId": string,
  "confidence": number,
  "pageAnchor": {
    object (PageAnchor)
  },
  "id": string,
  "normalizedValue": {
    object (NormalizedValue)
  },
  "properties": [
    {
      object (Entity)
    }
  ],
  "provenance": {
    object (Provenance)
  },
  "redacted": boolean
}
Fields
textAnchor

object (TextAnchor)

Optional. Provenance of the entity. Text anchor indexing into the Document.text.

type

string

Required. Entity type from a schema e.g. Address.

mentionText

string

Optional. Text value of the entity e.g. 1600 Amphitheatre Pkwy.

mentionId

string

Optional. Deprecated. Use id field instead.

confidence

number

Optional. Confidence of detected Schema entity. Range [0, 1].

pageAnchor

object (PageAnchor)

Optional. Represents the provenance of this entity wrt. the location on the page where it was found.

id

string

Optional. Canonical id. This will be a unique value in the entity list for this document.

normalizedValue

object (NormalizedValue)

Optional. Normalized entity value. Absent if the extracted value could not be converted or the type (e.g. address) is not supported for certain parsers. This field is also only populated for certain supported document types.

properties[]

object (Entity)

Optional. Entities can be nested to form a hierarchical data structure representing the content in the document.

provenance

object (Provenance)

Optional. The history of this annotation.

redacted

boolean

Optional. Whether the entity will be redacted for de-identification purposes.

PageAnchor

Referencing the visual context of the entity in the Document.pages. Page anchors can be cross-page, consist of multiple bounding polygons and optionally reference specific layout element types.

JSON representation
{
  "pageRefs": [
    {
      object (PageRef)
    }
  ]
}
Fields
pageRefs[]

object (PageRef)

One or more references to visual page elements

PageRef

Represents a weak reference to a page element within a document.

JSON representation
{
  "page": string,
  "layoutType": enum (LayoutType),
  "layoutId": string,
  "boundingPoly": {
    object (BoundingPoly)
  },
  "confidence": number
}
Fields
page

string (int64 format)

Required. Index into the Document.pages element, for example using [Document.pages][pageRefs.page] to locate the related page element. This field is skipped when its value is the default 0. See https://developers.google.com/protocol-buffers/docs/proto3#json.

layoutType

enum (LayoutType)

Optional. The type of the layout element that is being referenced if any.

layoutId
(deprecated)

string

Optional. Deprecated. Use PageRef.bounding_poly instead.

boundingPoly

object (BoundingPoly)

Optional. Identifies the bounding polygon of a layout element on the page. If layoutType is set, the bounding polygon must be exactly the same to the layout element it's referring to.

confidence

number

Optional. Confidence of detected page element, if applicable. Range [0, 1].

LayoutType

The type of layout that is being referenced.

Enums
LAYOUT_TYPE_UNSPECIFIED Layout Unspecified.
BLOCK References a Page.blocks element.
PARAGRAPH References a Page.paragraphs element.
LINE References a Page.lines element.
TOKEN References a Page.tokens element.
VISUAL_ELEMENT References a Page.visual_elements element.
TABLE Refrrences a Page.tables element.
FORM_FIELD References a Page.form_fields element.

NormalizedValue

Parsed and normalized entity value.

JSON representation
{
  "text": string,

  // Union field structured_value can be only one of the following:
  "moneyValue": {
    object (Money)
  },
  "dateValue": {
    object (Date)
  },
  "datetimeValue": {
    object (DateTime)
  },
  "addressValue": {
    object (PostalAddress)
  },
  "booleanValue": boolean,
  "integerValue": integer,
  "floatValue": number
  // End of list of possible types for union field structured_value.
}
Fields
text

string

Optional. An optional field to store a normalized string. For some entity types, one of respective structured_value fields may also be populated. Also not all the types of structured_value will be normalized. For example, some processors may not generate float or integer normalized text by default.

Below are sample formats mapped to structured values.

  • Money/Currency type (moneyValue) is in the ISO 4217 text format.
  • Date type (dateValue) is in the ISO 8601 text format.
  • Datetime type (datetimeValue) is in the ISO 8601 text format.
Union field structured_value. An optional structured entity value. Must match entity type defined in schema if known. If this field is present, the text field could also be populated. structured_value can be only one of the following:
moneyValue

object (Money)

Money value. See also: https://github.com/googleapis/googleapis/blob/master/google/type/money.proto

dateValue

object (Date)

Date value. Includes year, month, day. See also: https://github.com/googleapis/googleapis/blob/master/google/type/date.proto

datetimeValue

object (DateTime)

DateTime value. Includes date, time, and timezone. See also: https://github.com/googleapis/googleapis/blob/master/google/type/datetime.proto

addressValue

object (PostalAddress)

Postal address. See also: https://github.com/googleapis/googleapis/blob/master/google/type/postal_address.proto

booleanValue

boolean

Boolean value. Can be used for entities with binary values, or for checkboxes.

integerValue

integer

Integer value.

floatValue

number

Float value.

EntityRelation

Relationship between Entities.

JSON representation
{
  "subjectId": string,
  "objectId": string,
  "relation": string
}
Fields
subjectId

string

Subject entity id.

objectId

string

Object entity id.

relation

string

Relationship description.

TextChange

This message is used for text changes aka. OCR corrections.

JSON representation
{
  "textAnchor": {
    object (TextAnchor)
  },
  "changedText": string,
  "provenance": [
    {
      object (Provenance)
    }
  ]
}
Fields
textAnchor

object (TextAnchor)

Provenance of the correction. Text anchor indexing into the Document.text. There can only be a single TextAnchor.text_segments element. If the start and end index of the text segment are the same, the text change is inserted before that index.

changedText

string

The text that replaces the text identified in the textAnchor.

provenance[]
(deprecated)

object (Provenance)

The history of this annotation.

ShardInfo

For a large document, sharding may be performed to produce several document shards. Each document shard contains this field to detail which shard it is.

JSON representation
{
  "shardIndex": string,
  "shardCount": string,
  "textOffset": string
}
Fields
shardIndex

string (int64 format)

The 0-based index of this shard.

shardCount

string (int64 format)

Total number of shards.

textOffset

string (int64 format)

The index of the first character in Document.text in the overall document global text.

Revision

Contains past or forward revisions of this document.

JSON representation
{
  "id": string,
  "parent": [
    integer
  ],
  "parentIds": [
    string
  ],
  "createTime": string,
  "humanReview": {
    object (HumanReview)
  },

  // Union field source can be only one of the following:
  "agent": string,
  "processor": string
  // End of list of possible types for union field source.
}
Fields
id

string

Id of the revision, internally generated by doc proto storage. Unique within the context of the document.

parent[]
(deprecated)

integer

The revisions that this revision is based on. This can include one or more parent (when documents are merged.) This field represents the index into the revisions field.

parentIds[]

string

The revisions that this revision is based on. Must include all the ids that have anything to do with this revision - eg. there are provenance.parent.revision fields that index into this field.

createTime

string (Timestamp format)

The time that the revision was created, internally generated by doc proto storage at the time of create.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

humanReview

object (HumanReview)

Human Review information of this revision.

Union field source. Who/what made the change source can be only one of the following:
agent

string

If the change was made by a person specify the name or id of that person.

processor

string

If the annotation was made by processor identify the processor by its resource name.

HumanReview

Human Review information of the document.

JSON representation
{
  "state": string,
  "stateMessage": string
}
Fields
state

string

Human review state. e.g. requested, succeeded, rejected.

stateMessage

string

A message providing more details about the current state of processing. For example, the rejection reason when the state is rejected.

DocumentLayout

Represents the parsed layout of a document as a collection of blocks that the document is divided into.

JSON representation
{
  "blocks": [
    {
      object (DocumentLayoutBlock)
    }
  ]
}
Fields
blocks[]

object (DocumentLayoutBlock)

List of blocks in the document.

DocumentLayoutBlock

Represents a block. A block could be one of the various types (text, table, list) supported.

JSON representation
{
  "blockId": string,
  "pageSpan": {
    object (LayoutPageSpan)
  },

  // Union field block can be only one of the following:
  "textBlock": {
    object (LayoutTextBlock)
  },
  "tableBlock": {
    object (LayoutTableBlock)
  },
  "listBlock": {
    object (LayoutListBlock)
  }
  // End of list of possible types for union field block.
}
Fields
blockId

string

ID of the block.

pageSpan

object (LayoutPageSpan)

Page span of the block.

Union field block.

block can be only one of the following:

textBlock

object (LayoutTextBlock)

Block consisting of text content.

tableBlock

object (LayoutTableBlock)

Block consisting of table content/structure.

listBlock

object (LayoutListBlock)

Block consisting of list content/structure.

LayoutTextBlock

Represents a text type block.

JSON representation
{
  "text": string,
  "type": string,
  "blocks": [
    {
      object (DocumentLayoutBlock)
    }
  ]
}
Fields
text

string

Text content stored in the block.

type

string

Type of the text in the block. Available options are: paragraph, subtitle, heading-1, heading-2, heading-3, heading-4, heading-5, header, footer.

blocks[]

object (DocumentLayoutBlock)

A text block could further have child blocks. Repeated blocks support further hierarchies and nested blocks.

LayoutTableBlock

Represents a table type block.

JSON representation
{
  "headerRows": [
    {
      object (LayoutTableRow)
    }
  ],
  "bodyRows": [
    {
      object (LayoutTableRow)
    }
  ],
  "caption": string
}
Fields
headerRows[]

object (LayoutTableRow)

Header rows at the top of the table.

bodyRows[]

object (LayoutTableRow)

Body rows containing main table content.

caption

string

Table caption/title.

LayoutTableRow

Represents a row in a table.

JSON representation
{
  "cells": [
    {
      object (LayoutTableCell)
    }
  ]
}
Fields
cells[]

object (LayoutTableCell)

A table row is a list of table cells.

LayoutTableCell

Represents a cell in a table row.

JSON representation
{
  "blocks": [
    {
      object (DocumentLayoutBlock)
    }
  ],
  "rowSpan": integer,
  "colSpan": integer
}
Fields
blocks[]

object (DocumentLayoutBlock)

A table cell is a list of blocks. Repeated blocks support further hierarchies and nested blocks.

rowSpan

integer

How many rows this cell spans.

colSpan

integer

How many columns this cell spans.

LayoutListBlock

Represents a list type block.

JSON representation
{
  "listEntries": [
    {
      object (LayoutListEntry)
    }
  ],
  "type": string
}
Fields
listEntries[]

object (LayoutListEntry)

List entries that constitute a list block.

type

string

Type of the listEntries (if exist). Available options are ordered and unordered.

LayoutListEntry

Represents an entry in the list.

JSON representation
{
  "blocks": [
    {
      object (DocumentLayoutBlock)
    }
  ]
}
Fields
blocks[]

object (DocumentLayoutBlock)

A list entry is a list of blocks. Repeated blocks support further hierarchies and nested blocks.

LayoutPageSpan

Represents where the block starts and ends in the document.

JSON representation
{
  "pageStart": integer,
  "pageEnd": integer
}
Fields
pageStart

integer

Page where block starts in the document.

pageEnd

integer

Page where block ends in the document.

ChunkedDocument

Represents the chunks that the document is divided into.

JSON representation
{
  "chunks": [
    {
      object (Chunk)
    }
  ]
}
Fields
chunks[]

object (Chunk)

List of chunks.

Chunk

Represents a chunk.

JSON representation
{
  "chunkId": string,
  "sourceBlockIds": [
    string
  ],
  "content": string,
  "pageSpan": {
    object (ChunkPageSpan)
  },
  "pageHeaders": [
    {
      object (ChunkPageHeader)
    }
  ],
  "pageFooters": [
    {
      object (ChunkPageFooter)
    }
  ]
}
Fields
chunkId

string

ID of the chunk.

sourceBlockIds[]

string

Unused.

content

string

Text content of the chunk.

pageSpan

object (ChunkPageSpan)

Page span of the chunk.

pageHeaders[]

object (ChunkPageHeader)

Page headers associated with the chunk.

pageFooters[]

object (ChunkPageFooter)

Page footers associated with the chunk.

ChunkPageSpan

Represents where the chunk starts and ends in the document.

JSON representation
{
  "pageStart": integer,
  "pageEnd": integer
}
Fields
pageStart

integer

Page where chunk starts in the document.

pageEnd

integer

Page where chunk ends in the document.

ChunkPageHeader

Represents the page header associated with the chunk.

JSON representation
{
  "text": string,
  "pageSpan": {
    object (ChunkPageSpan)
  }
}
Fields
text

string

Header in text format.

pageSpan

object (ChunkPageSpan)

Page span of the header.

ChunkPageFooter

Represents the page footer associated with the chunk.

JSON representation
{
  "text": string,
  "pageSpan": {
    object (ChunkPageSpan)
  }
}
Fields
text

string

Footer in text format.

pageSpan

object (ChunkPageSpan)

Page span of the footer.