# Google Cloud Document Ai V1 Client - Class Document (2.7.0)

2.7.0 (latest) 2.6.1 2.5.1 2.4.1 2.3.0 2.2.2 2.1.3 2.0.0 1.14.0 1.13.1 1.12.2 1.9.0 1.8.2 1.7.0 1.6.0 1.5.0 1.4.0 1.3.0 1.2.2 1.1.1 1.0.1 Reference documentation and code samples for the Google Cloud Document Ai V1 Client class 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.

Generated from protobuf message `google.cloud.documentai.v1.Document`

## Namespace

Google \\ Cloud \\ DocumentAI \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ 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](https://cloud.google.com/storage/docs/reference-uris). |
| `↳ content` | `string` 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. |
| `↳ docid` | `string` Optional. An internal identifier for document. Should be loggable (no PII). |
| `↳ mime_type` | `string` An IANA published [media type (MIME type)](https://www.iana.org/assignments/media-types/media-types.xhtml). |
| `↳ text` | `string` Optional. UTF-8 encoded text in reading order from the document. |
| `↳ text_styles` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.Style>` Styles for the [Document.text](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getText__). |
| `↳ pages` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.Page>` Visual page layout for the [Document](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document). |
| `↳ entities` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.Entity>` A list of entities detected on [Document.text](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getText__). For document shards, entities in this list may cross shard boundaries. |
| `↳ entity_relations` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.EntityRelation>` Placeholder. Relationship among [Document.entities](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getEntities__). |
| `↳ text_changes` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.TextChange>` Placeholder. A list of text corrections made to [Document.text](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getText__). This is usually used for annotating corrections to OCR mistakes. Text changes for a given revision may not overlap with each other. |
| `↳ shard_info` | `https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.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` | `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Rpc.Status.html` Any error that occurred while processing this document. |
| `↳ revisions` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.Revision>` Placeholder. Revision history of this document. |
| `↳ document_layout` | `https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.DocumentLayout` Parsed layout of the document. |
| `↳ chunked_document` | `https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.ChunkedDocument` Document chunked based on chunking config. |
| `↳ blob_assets` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.BlobAsset>` Optional. The blob assets in this document. This is used to store the content of the inline blobs in this document, for example, image bytes, such that it can be referenced by other fields in the document via asset id. |
| `↳ entity_validation_output` | `https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.EntityValidationOutput` The entity validation output for the document. This is the validation output for `document.entities` field. |
| `↳ entities_revisions` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.EntitiesRevision>` A list of entity revisions. The entity revisions are appended to the document in the processing order. This field can be used for comparing the entity extraction results at different stages of the processing. |
| `↳ entities_revision_id` | `string` The entity revision ID that `document.entities` field is based on. If this field is set and `entities_revisions` is not empty, the entities in `document.entities` field are the entities in the entity revision with this id and `document.entity_validation_output` field is the `entity_validation_output` field in this entity revision. |

### getUri

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](https://cloud.google.com/storage/docs/reference-uris).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### hasUri

### setUri

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](https://cloud.google.com/storage/docs/reference-uris).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getContent

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.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### hasContent

### setContent

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.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDocid

Optional. An internal identifier for document. Should be loggable (no PII).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setDocid

Optional. An internal identifier for document. Should be loggable (no PII).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getMimeType

An IANA published [media type (MIME
type)](https://www.iana.org/assignments/media-types/media-types.xhtml).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setMimeType

An IANA published [media type (MIME
type)](https://www.iana.org/assignments/media-types/media-types.xhtml).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getText

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setText

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

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getTextStyles

Styles for the [Document.text](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getText__).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.Style>` |   |

### setTextStyles

Styles for the [Document.text](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getText__).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.Style>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getPages

Visual page layout for the [Document](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.Page>` |   |

### setPages

Visual page layout for the [Document](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.Page>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getEntities

A list of entities detected on
[Document.text](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getText__). For document
shards, entities in this list may cross shard boundaries.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.Entity>` |   |

### setEntities

A list of entities detected on
[Document.text](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getText__). For document
shards, entities in this list may cross shard boundaries.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.Entity>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getEntityRelations

Placeholder. Relationship among
[Document.entities](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getEntities__).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.EntityRelation>` |   |

### setEntityRelations

Placeholder. Relationship among
[Document.entities](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getEntities__).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.EntityRelation>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getTextChanges

Placeholder. A list of text corrections made to
[Document.text](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getText__). This is usually
used for annotating corrections to OCR mistakes. Text changes for a given
revision may not overlap with each other.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.TextChange>` |   |

### setTextChanges

Placeholder. A list of text corrections made to
[Document.text](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getText__). This is usually
used for annotating corrections to OCR mistakes. Text changes for a given
revision may not overlap with each other.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.TextChange>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getShardInfo

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.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.ShardInfo|null` |   |

### hasShardInfo

### clearShardInfo

### setShardInfo

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.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.ShardInfo` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getError

Any error that occurred while processing this document.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Rpc.Status.html|null` |   |

### hasError

### clearError

### setError

Any error that occurred while processing this document.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/common-protos/latest/Rpc.Status.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRevisions

Placeholder. Revision history of this document.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.Revision>` |   |

### setRevisions

Placeholder. Revision history of this document.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.Revision>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getDocumentLayout

Parsed layout of the document.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.DocumentLayout|null` |   |

### hasDocumentLayout

### clearDocumentLayout

### setDocumentLayout

Parsed layout of the document.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.DocumentLayout` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getChunkedDocument

Document chunked based on chunking config.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.ChunkedDocument|null` |   |

### hasChunkedDocument

### clearChunkedDocument

### setChunkedDocument

Document chunked based on chunking config.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.ChunkedDocument` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getBlobAssets

Optional. The blob assets in this document. This is used to store the
content of the inline blobs in this document, for example, image bytes,
such that it can be referenced by other fields in the document via asset
id.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.BlobAsset>` |   |

### setBlobAssets

Optional. The blob assets in this document. This is used to store the
content of the inline blobs in this document, for example, image bytes,
such that it can be referenced by other fields in the document via asset
id.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.BlobAsset>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getEntityValidationOutput

The entity validation output for the document. This is the validation
output for `document.entities` field.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.EntityValidationOutput|null` |   |

### hasEntityValidationOutput

### clearEntityValidationOutput

### setEntityValidationOutput

The entity validation output for the document. This is the validation
output for `document.entities` field.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.EntityValidationOutput` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getEntitiesRevisions

A list of entity revisions. The entity revisions are appended to the
document in the processing order. This field can be used for comparing the
entity extraction results at different stages of the processing.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.EntitiesRevision>` |   |

### setEntitiesRevisions

A list of entity revisions. The entity revisions are appended to the
document in the processing order. This field can be used for comparing the
entity extraction results at different stages of the processing.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.EntitiesRevision>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getEntitiesRevisionId

The entity revision ID that `document.entities` field is based on.

If this field is set and `entities_revisions` is not empty, the entities in
`document.entities` field are the entities in the entity revision with this
id and `document.entity_validation_output` field is the
`entity_validation_output` field in this entity revision.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setEntitiesRevisionId

The entity revision ID that `document.entities` field is based on.

If this field is set and `entities_revisions` is not empty, the entities in
`document.entities` field are the entities in the entity revision with this
id and `document.entity_validation_output` field is the
`entity_validation_output` field in this entity revision.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getSource

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |