# Google Cloud Document Ai V1 Client - Class TextSegment (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 TextSegment.

A text segment in the
[Document.text](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getText__). 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](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.ShardInfo#_Google_Cloud_DocumentAI_V1_Document_ShardInfo__getTextOffset__)

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

## Namespace

Google \\ Cloud \\ DocumentAI \\ V1 \\ Document \\ TextAnchor

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ start_index` | `int|string` [TextSegment](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.TextAnchor.TextSegment) start UTF-8 char index in the [Document.text](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getText__). |
| `↳ end_index` | `int|string` [TextSegment](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.TextAnchor.TextSegment) half open end UTF-8 char index in the [Document.text](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document#_Google_Cloud_DocumentAI_V1_Document__getText__). |

### getStartIndex

[TextSegment](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.TextAnchor.TextSegment)
start UTF-8 char index in 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** |
| `int|string` |   |

### setStartIndex

[TextSegment](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.TextAnchor.TextSegment)
start UTF-8 char index in 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` | `int|string` |

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

### getEndIndex

[TextSegment](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.TextAnchor.TextSegment)
half open end UTF-8 char index in 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** |
| `int|string` |   |

### setEndIndex

[TextSegment](https://docs.cloud.google.com/php/docs/reference/cloud-document-ai/latest/V1.Document.TextAnchor.TextSegment)
half open end UTF-8 char index in 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` | `int|string` |

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