# IRPCScanningAndOCR.OCROperation_Begin

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) > [Scanning and OCR](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/index.md)

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

Badges: `Vault API / standard` `write` `session` `idempotent` `returns metadata structure version`

Starts an OCR job on a file of a document that the caller has checked out.

- **Service:** [Scanning and OCR](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/index.md) `MFiles.IRPCScanningAndOCR`
- **gRPC method:** `/MFiles.IRPCScanningAndOCR/OCROperation_Begin`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/ocroperation_-begin`
- **Request:** [`OCROperation_BeginRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_Begin/index.md#request)
- **Response:** [`OCROperation_BeginResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_Begin/index.md#response)
- **Book and level:** Vault API, standard
- **Kind:** write
- **Session:** Required: the session ID from LogIn in the mfiles-session-id-bin metadata.
- **Idempotent:** yes
- **Returns metadata structure version:** yes (in the mfiles-metadata-version-bin trailer)
- **Streaming:** none (unary)

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

## Remarks

- The document must be checked out to the caller, and the caller needs read and edit access to
  it. The initial checked-out version of a new document (version 1) is rejected: it has no
  checked-in version.
- Nothing is uploaded: the content is read from the file in the latest checked-in version of
  the document.
- Finish with [OCROperation_End](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_End/index.md) to replace
  the file in the checked-out version with the PDF, then check the document in.

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

## Request: OCROperation_BeginRequest

> 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 |
|---|---|---|
| `type` | [`OCROperationType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.OCROperationType/index.md) | What to produce. See the service overview. Values: `OCROPERATION_TYPE_NONE` (0), `OCROPERATION_TYPE_CONVERT_TO_SEARCHABLE_PDF` (1), `OCROPERATION_TYPE_RECOGNIZE_SPECIFIC_BLOCKS` (2), `OCROPERATION_TYPE_RECOGNIZE_ANY_BLOCKS` (3), `OCROPERATION_TYPE_CONVERT_TO_SEARCHABLE_PDF_AND_RECOGNIZE_SPECIFIC_BLOCKS` (4), `OCROPERATION_TYPE_CONVERT_TO_SEARCHABLE_PDF_AND_RECOGNIZE_ANY_BLOCKS` (5), `OCROPERATION_TYPE_CONVERT_TO_SEARCHABLE_ARCHIVE_PDF` (6), `OCROPERATION_TYPE_CONVERT_TO_SEARCHABLE_ARCHIVE_PDF_AND_RECOGNIZE_SPECIFIC_BLOCKS` (7), `OCROPERATION_TYPE_CONVERT_TO_SEARCHABLE_ARCHIVE_PDF_AND_RECOGNIZE_ANY_BLOCKS` (8). |
| `options` | [`OCROptions`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OCROptions/index.md) | Recognition languages and automatic language detection. Unset uses the defaults. |
| `options.languages[]` | repeated [`OCRLanguageType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.OCRLanguageType/index.md) | Languages/character sets/dictionaries to be used as recognition hints. Can be unset. |
| `options.ocr_automatic_language_detection` | `bool` | True if the OCR automatic language detection is to be used. |
| `obj_or_file_ver` | [`ObjOrFileVer`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjOrFileVer/index.md) | The checked-out version (`obj_ver`) and the file (`file_ver`) to process. |
| `obj_or_file_ver.obj_ver` | [`ObjVer`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjVer/index.md) | Object version. The version part can be -1 to indicate the latest version. |
| `obj_or_file_ver.obj_ver.obj_id` | [`ObjID`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjID/index.md) | The object. |
| `obj_or_file_ver.obj_ver.version` | [`ObjVerVersion`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjVerVersion/index.md) | The version. Usually `OBJ_VER_VERSION_TYPE_SPECIFIC` with `internal_version`. |
| `obj_or_file_ver.file_ver` | [`FileVer`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.FileVer/index.md) | File version. Valid only if bIsFile is true. |
| `obj_or_file_ver.file_ver.file_id` | [`FileID`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.FileID/index.md) | The file. |
| `obj_or_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_or_file_ver.file_ver.internal_version` | `int32` | The file version number. |
| `obj_or_file_ver.file_ver.external_repository_version` | `string` | Used only for files in external repositories. Leave empty. |
| `obj_or_file_ver.file_ver.external_repository_sort_key` | `int64` | Used only for files in external repositories. Leave 0. |
| `source_file_extension` | `string` | The file name extension, without the dot. |
| `pages` | [`OCRPageArray`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OCRPageArray/index.md) | For `..._RECOGNIZE_SPECIFIC_BLOCKS` types, the areas to recognize. Otherwise unset. |
| `pages.value[]` | repeated [`OCRPage`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OCRPage/index.md) | An array of OCR pages, should be ordered by the page number. |
| `pages.value[].number` | `uint32` | Page number of this page. |
| `pages.value[].blocks[]` | repeated [`OCRBlock`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OCRBlock/index.md) | An array of OCR blocks. |

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

## Response: OCROperation_BeginResponse

> 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 |
|---|---|---|
| `background_op_id` | `uint32` | The ID of the job. |

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

## Related methods

- [OCROperation_End](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_End/index.md): Ends an OCR job started with OCROperation_Begin and replaces the document's file with the resulting PDF.
- [OCROperation_Status](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_Status/index.md): Gets the progress of an OCR job, and optionally cancels it.
- [OCROperation_BeginAfterUpload](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_BeginAfterUpload/index.md): Starts an OCR job on a file that the caller uploaded with UploadTempFile.
- [OCROperation_EndWithDownload](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_EndWithDownload/index.md): Ends an OCR job and returns its results: the recognized texts and a download of the PDF.
