# IRPCScanningAndOCR.OCROperation_EndWithDownload

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

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

Ends an OCR job and returns its results: the recognized texts and a download of the 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_EndWithDownload`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/ocroperation_-end-with-download`
- **Request:** [`OCROperation_EndWithDownloadRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_EndWithDownload/index.md#request)
- **Response:** [`OCROperation_EndWithDownloadResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_EndWithDownload/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

- Call after [OCROperation_Status](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScanningAndOCR/OCROperation_Status/index.md)
  reports `done`. The job is released; the ID cannot be used again.
- For the types that produce a PDF, read the file with
  [DownloadFile_ReadBlock](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_ReadBlock/index.md) using
  `download_session`, and release the download with
  [DownloadFile_Stop](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_Stop/index.md). For the
  recognize-only types `download_file_size` is 0.
- If the job failed, the call fails with the job's error.

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

## Request: OCROperation_EndWithDownloadRequest

> 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_EndWithDownloadResponse

> 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 for the types that only produce a PDF. |
| `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. |
| `download_session` | `int32` | The download ID of the resulting PDF. |
| `download_file_size` | `int64` | The size of the resulting PDF in bytes; 0 if none. |

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

## Related methods

- [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.
- [IRPCObjectOperations.DownloadFile_ReadBlock](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_ReadBlock/index.md): Reads a block of a file from a download session.
- [IRPCObjectOperations.DownloadFile_Stop](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DownloadFile_Stop/index.md): Closes a download session.
- [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_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_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.
