# IRPCObjectOperations.GetTextContentForFileWithFormat

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Vault API](https://developer.m-files.com/APIs/gRPC-API/vault/index.md) > [Objects, versions, properties and files](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/GetTextContentForFileWithFormat/

Badges: `Vault API / core` `read` `session or assertion` `idempotent` `returns metadata structure version`

Gets the text content of a file version as plain text or Markdown, and reports which format was
produced.

- **Service:** [Objects, versions, properties and files](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/index.md) `MFiles.IRPCObjectOperations`
- **gRPC method:** `/MFiles.IRPCObjectOperations/GetTextContentForFileWithFormat`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/get-text-content-for-file-with-format`
- **Request:** [`GetTextContentForFileWithFormatRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/GetTextContentForFileWithFormat/index.md#request)
- **Response:** [`GetTextContentForFileWithFormatResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/GetTextContentForFileWithFormat/index.md#response)
- **Book and level:** Vault API, core
- **Kind:** read
- **Session:** Required: a session (mfiles-session-id-bin metadata) or a session assertion (x-mf-session-assertion metadata).
- **Idempotent:** yes
- **Returns metadata structure version:** yes (in the mfiles-metadata-version-bin trailer)
- **Streaming:** none (unary)

<a id="remarks"></a>

## Remarks

Supported when the server's [ServerVaultCapabilities](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ServerVaultCapabilities/index.md)
`get_text_content_with_format_supported` is true. Request `FILE_FORMAT_MARKDOWN` or
`FILE_FORMAT_PLAIN_TEXT`; any other format returns plain text. Always read `format_produced`: it
tells the format of `text_content`, which can be plain text even if Markdown was requested.

<a id="request"></a>

## Request: GetTextContentForFileWithFormatRequest

The request of GetTextContentForFileWithFormat: the file version and the requested text format.

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `obj_file_ver` | [`ObjFileVer`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjFileVer/index.md) | The object and the specific file version. |
| `obj_file_ver.obj_id` | [`ObjID`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjID/index.md) | The object that owns the file. |
| `obj_file_ver.obj_id.type` | `int32` | The object type ID, for example 0 for documents. In a lookup value, the value list ID (for a lookup to objects, the object type ID). |
| `obj_file_ver.obj_id.item_id` | [`ItemID`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ItemID/index.md) | The ID of the object within its type, in `item_id.internal_id`. |
| `obj_file_ver.file_ver` | [`FileVer`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.FileVer/index.md) | The specific file version, as in `File.file_ver`. |
| `obj_file_ver.file_ver.file_id` | [`FileID`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.FileID/index.md) | The file. |
| `obj_file_ver.file_ver.type` | [`FileVerType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.FileVerType/index.md) | `FILE_VER_TYPE_SPECIFIC` for a file version number. Values: `FILE_VER_TYPE_UNINITIALIZED` (0), `FILE_VER_TYPE_LATEST` (1), `FILE_VER_TYPE_ANY` (2), `FILE_VER_TYPE_SPECIFIC` (3). |
| `obj_file_ver.file_ver.internal_version` | `int32` | The file version number. |
| `obj_file_ver.file_ver.external_repository_version` | `string` | Used only for files in external repositories. Leave empty. |
| `obj_file_ver.file_ver.external_repository_sort_key` | `int64` | Used only for files in external repositories. Leave 0. |
| `option_flags` | [`TEXTCONTENTEXTRACTIONFLAGS`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.TEXTCONTENTEXTRACTIONFLAGS/index.md) | Extraction flags. Leave unset for a fresh extraction. |
| `option_flags.all` | `bool` | Specifies all flags set; Including any future flags. |
| `option_flags.unpackcontainers` | `bool` | Unpack container files. |
| `option_flags.useplaintextcache` | `bool` | Use plain text cache. This makes other options, such as UNPACKCONTAINERS and max. content size ineffective. The operation returns the text content in same way it is returned for e.g. search indexing. |
| `requested_format` | [`FileFormat`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.FileFormat/index.md) | `FILE_FORMAT_MARKDOWN` or `FILE_FORMAT_PLAIN_TEXT`. Values: `FILE_FORMAT_NATIVE` (0), `FILE_FORMAT_PDF` (1), `FILE_FORMAT_DISPLAY_ONLY_PDF` (2), `FILE_FORMAT_PLAIN_TEXT` (3), `FILE_FORMAT_MARKDOWN` (4). |

<a id="response"></a>

## Response: GetTextContentForFileWithFormatResponse

The response of GetTextContentForFileWithFormat: the text and the format it was produced in.

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `text_content` | `string` | The text, in the format given in `format_produced`. |
| `format_produced` | [`FileFormat`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.FileFormat/index.md) | The format of `text_content`. Values: `FILE_FORMAT_NATIVE` (0), `FILE_FORMAT_PDF` (1), `FILE_FORMAT_DISPLAY_ONLY_PDF` (2), `FILE_FORMAT_PLAIN_TEXT` (3), `FILE_FORMAT_MARKDOWN` (4). |

<a id="related"></a>

## Related methods

- [GetTextContentForFile](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/GetTextContentForFile/index.md): Gets the plain text content of a file version.
