# IRPCScanningAndOCR.OCROperation_End

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_End/

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

Ends an OCR job started with OCROperation_Begin and replaces the document's file with the
resulting PDF.

- **Service:** [Scanning and OCR](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/index.md) `MFiles.IRPCScanningAndOCR`
- **gRPC method:** `/MFiles.IRPCScanningAndOCR/OCROperation_End`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/ocroperation_-end`
- **Request:** [`OCROperation_EndRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_End/index.md#request)
- **Response:** [`OCROperation_EndResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_End/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:** no
- **Returns metadata structure version:** yes (in the mfiles-metadata-version-bin trailer)
- **Streaming:** none (unary)

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

## Remarks

- Only for jobs started with
  [OCROperation_Begin](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_Begin/index.md); other jobs fail
  with "OCR processing has not been started.".
- For the types that produce a PDF, the file in the checked-out version is replaced with the
  PDF and its extension changes to `pdf`. Check the document in to save the change.
- The job is released; the ID cannot be used again. If the job failed, the call fails with the
  job's error.

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

## Request: OCROperation_EndRequest

> 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="response"></a>

## Response: OCROperation_EndResponse

> 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 |
|---|---|---|
| `page_results[]` | repeated [`OCRPageResult`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OCRPageResult/index.md) | The recognized areas and their texts, per page. Empty if the type did not recognize areas. |
| `page_results[].number` | `uint32` | Page number of this page. |
| `page_results[].blocks[]` | repeated [`OCRBlockResult`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OCRBlockResult/index.md) | An array of OCR block results. |
| `page_results[].blocks[].id` | `int32` | Id of the OCR block. Negative value if there was no request block. |
| `page_results[].blocks[].dimension_unit` | [`OCRBlockDimUnitType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.OCRBlockDimUnitType/index.md) | Defines the unit of the block rectangle dimensions. Default is pixels. Values: `OCRBLOCK_DIM_UNIT_TYPE_PIXELS` (0), `OCRBLOCK_DIM_UNIT_TYPE_MILLIMETERS_X10` (1), `OCRBLOCK_DIM_UNIT_TYPE_INCHES_X100` (2). |
| `page_results[].blocks[].left` | `uint32` | Distance from the left of the image. |
| `page_results[].blocks[].top` | `uint32` | Distance from the top of the image. |
| `page_results[].blocks[].width` | `uint32` | Width of the block rectangle. |
| `page_results[].blocks[].height` | `uint32` | Height of the block rectangle. |
| `page_results[].blocks[].confidence` | `int32` | Confidence level (0 = most confident, 255 = least confident). |
| `page_results[].blocks[].page` | `uint32` | One-based number of the page on which this result was recognized. 0 means no recognition. |
| `page_results[].blocks[].value` | [`TypedValue`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.TypedValue/index.md) | The recognized value. |

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

## Related methods

- [OCROperation_Begin](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_Begin/index.md): Starts an OCR job on a file of a document that the caller has checked out.
- [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.
