---
title: "Easiest Way to OCR Process PDF Documents in ASP.NET Core"
published_at: "2020-05-07T10:30:27+00:00"
modified_at: "2026-07-01T12:36:23+00:00"
url: "https://www.syncfusion.com/blogs/post/easiest-way-to-ocr-process-pdf-documents-in-asp-net-core"
excerpt: "Optical character recognition (OCR) is a technology used to convert scanned paper documents, in the form of PDF files or images, into searchable, editable data. The Syncfusion OCR processor library has extended support to OCR process PDF documents and other..."
taxonomy_category:
  - ".NET Core"
  - "ASP.NET Core"
  - "PDF"
taxonomy_post_tag:
  - ".NET Core"
  - "ASP.NET Core"
  - "OCR"
  - "PDF"
---

# Easiest Way to OCR Process PDF Documents in ASP.NET Core

[Praveenkumar](https://www.syncfusion.com/blogs/author/praveenh)

![Easiest Way to OCR Process PDF documents in ASP.NET core_edited](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/Easiest-Way-to-OCR-Process-PDF-documents-in-ASP.NET-core_edited.jpg)


Optical character recognition (OCR) is a technology used to convert scanned paper documents, in the form of PDF files or images, into searchable, editable data.

The [Syncfusion OCR processor library](https://www.syncfusion.com/document-processing/pdf-framework/net/pdf-library/ocr-process)
 has extended support to OCR process PDF documents and other scanned images in the .NET Core platform from version [18.1.0.42](https://www.syncfusion.com/forums/152921/essential-studio-2020-volume-1-release-v18-1-0-42-is-available-for-download)
. In this blog, I am going to create an ASP.NET Core web application to OCR process a PDF document. The steps are:

- [Create an ASP.NET Core web application](#_Create_an_Asp.Net) .
- [Install necessary NuGet packages to OCR process PDF document](#_Install_necessary_Nuget) .
- [Perform OCR on PDF document](#_Perform_OCR_on) .
- [Publish OCR application in Azure App S](#_Publish_OCR_in)

Add Seamless PDF Viewing to ASP.NET Core Apps

Embed a fast, secure PDF viewer into your ASP.NET Core apps with Syncfusion ASP.NET Core PDF Viewer SDK. Display documents accurately, navigate pages, search text, annotate PDFs, fill forms, and handle large files with smooth performance.

[Add ASP.NET Core PDF Viewer](https://www.syncfusion.com/pdf-viewer-sdk/asp-net-core-pdf-viewer)

## Create an ASP.NET Core web application

Follow these steps to create an ASP.NET Core web application in Visual Studio 2019:

1. In Visual Studio 2019, go to **File** > ** New** and then select ** Project.**
2. Select **Create a new project**.
3. Select the **ASP.NET Core Web Application** template.
4. Enter the **Project name** and then click ** Create**. The Project template dialog will be displayed.

![Create a new ASP.NET Core Web application dialog box](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/Create-a-new-ASP.NET-Core-Web-application-dialog-box.png)

## Install necessary NuGet packages to OCR process PDF documents

Follow these steps to install the [Syncfusion.PDF.OCR.Net.Core](https://www.nuget.org/packages/Syncfusion.PDF.OCR.Net.Core/)
 NuGet package in the project:

1. Right-click on the project and select **Manage NuGet**** Packages. ![Select Mange NuGet Packages](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/Select-Mange-NuGet-Packages.png)**
2. Search for the [Syncfusion.PDF.OCR.Net.Core](https://www.nuget.org/packages/Syncfusion.PDF.OCR.Net.Core/) package and install it.![Select Syncfusion.PDF.OCR.NET.Core and install](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/Select-Syncfusion.PDF.OCR_.NET_.Core_.png)


## Perform OCR processing on PDF document

Follow these steps to perform OCR processing on a PDF document in ASP.NET Core:

1. Syncfusion’s OCR processor internally uses Tesseract libraries to perform OCR, so please copy the necessary tessdata and TesseractBinaries folders from the NuGet package folder to the project folder to use the OCR feature. The tessdata folder contains OCR language data and Tesseractbinaries contains the wrapper assemblies for Tesseract OCR. Please use the following link to download OCR language data for other languages. [https://github.com/tesseract-ocr/tessdata](https://github.com/tesseract-ocr/tessdata) ![Copy tessdata and tesseractbinaries folder from NuGet folder](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/Copy-tessdata-and-tesseractbinaries-folder-from-NuGet-folder.png) ![Paste tessdata and TesseractBinaries to the project folder](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/Paste-tessdata-and-tesseractbinaries-to-the-project-folder-3.png)
2. Set **Copy to Output Directory** to ** Copy if newer** for Data, tessdata, and TesseractBinaries folders.![Set Copy to Output Directory to Copy if newer](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/Set-Copy-to-Output-Directory-to-Copy-if-newer.png)
3. Add a new button in index.cshtml.``` @{ Html.BeginForm("PerformOCR", "Home", FormMethod.Post); { <input type="submit" value="Perform OCR" class=" btn" /> } } ```
4. Include the following namespaces in HomeController.cs.``` using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Syncfusion.OCRProcessor; using Syncfusion.Pdf.Graphics; using Syncfusion.Pdf.Parsing; using System.IO; ```
5. Include the following code example in HomeController.cs to perform the OCR processing.``` public IActionResult PerformOCR() { string binaries = Path.Combine(_hostingEnvironment.ContentRootPath, "TesseractBinaries", "Windows"); //Initialize OCR processor with tesseract binaries. OCRProcessor processor = new OCRProcessor(binaries); //Set language to the OCR processor. processor.Settings.Language = Languages.English; string path = Path.Combine(_hostingEnvironment.ContentRootPath, "Data", "times.ttf"); FileStream fontStream = new FileStream(path, FileMode.Open); //Create a true type font to support unicode characters in PDF. processor.UnicodeFont = new PdfTrueTypeFont(fontStream, 8); //Set temporary folder to save intermediate files. processor.Settings.TempFolder = Path.Combine(_hostingEnvironment.ContentRootPath, "Data"); //Load a PDF document. FileStream inputDocument = new FileStream(Path.Combine(_hostingEnvironment.ContentRootPath, "Data", "PDF_succinctly.pdf"), FileMode.Open); PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputDocument); //Perform OCR with language data. string tessdataPath = Path.Combine(_hostingEnvironment.ContentRootPath, "Tessdata"); processor.PerformOCR(loadedDocument, tessdataPath); //Save the PDF document. MemoryStream outputDocument = new MemoryStream(); loadedDocument.Save(outputDocument); outputDocument.Position = 0; //Dispose OCR processor and PDF document. processor.Dispose(); loadedDocument.Close(true); //Download the PDF document in the browser. FileStreamResult fileStreamResult = new FileStreamResult(outputDocument, "application/pdf"); fileStreamResult.FileDownloadName = "OCRed_PDF_document.pdf"; return fileStreamResult; } ```

By executing this example, you will get the PDF document shown in the following image.

![OCRed PDF document](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/OCRed-PDF-document.png)


## Publish OCR application in Azure App Service

Follow these steps to publish the OCR application in Azure App Service:

1. In Solution Explorer, right-click the project and choose **Publish** (or use the ** Build** > ** Publish** menu item).![Choose Publish from the given option](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/Choose-Publish-option.png)
2. In the **Pick a publish target** dialog box, choose ** App Service**, select ** Create New** and click ** Create Profile**.![Pick a publish target dialog](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/Pick-a-publish-target-dialog.png)
3. In the Create App Service dialog box that appears, sign in with your Azure account (if necessary). Then, the default app service settings populate the fields. Click **Create**. ![Create App Service Dialog](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/Create-App-Service-Dialog.png)
4. Visual Studio now deploys the app to your Azure App Service, and the web app loads in your browser. The project properties Publish pane shows the site URL and other details. Click **Publish** to publish the application in Azure App Service. ![Publish Window](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/Publish-Window.png)

After publishing the application, you can perform OCR processing by navigating to the site URL.

![Perform OCR PDF Document](https://www.syncfusion.com/blogs/wp-content/uploads/2020/05/Perform-OCR-PDF-Document.png)

**Note:** Adobe provides an easy-to-use method for turning scanned files into editable PDF documents instantly, with editable text and custom fonts that look just like the original file. For more details, refer to the article [How to edit scanned documents](https://www.adobe.com/acrobat/how-to/ocr-software-convert-pdf-to-text.html)
.

## GitHub reference

You can find examples of [performing OCR on ASP.NET Core applications and Azure App Service](https://github.com/SyncfusionExamples/perform-ocr-on-pdf-net-core)
 in the GitHub repository.


## Conclusion

In this blog post, we have learned to perform OCR processing on PDF documents in ASP.NET Core web applications and publish the applications in Azure App Service.

Take a moment to peruse our [documentation](https://help.syncfusion.com/file-formats/pdf/working-with-ocr/dot-net-core)
, where you’ll find other options and features, all with accompanying code examples.

If you have any questions about these features, please let us know in the comments below. You can also contact us through our [support forum](https://www.syncfusion.com/forums)
, [Direct-Trac](https://www.syncfusion.com/support/directtrac/)
, or [feedback portal](https://www.syncfusion.com/feedback/pdf)
. We are happy to assist you!

If you liked this article, we think you would also like the following articles about our PDF Library:

- [Create and Validate PDF Digital Signatures in C#](https://www.syncfusion.com/blogs/post/create-validate-pdf-digital-signatures-csharp.aspx)
- [How to Find Corrupted PDF Files in C# Easily](https://www.syncfusion.com/blogs/post/how-to-find-corrupted-pdf-files-in-c-sharp.aspx)
- [How to Convert an Image to PDF in ASP.NET Core](https://www.syncfusion.com/blogs/post/how-to-convert-image-to-pdf-in-asp-net-core.aspx)
- [Easy Ways to Redact PDFs Using C#](https://www.syncfusion.com/blogs/post/easy-ways-to-redact-pdfs-using-c.aspx)
- [7 Ways to Compress PDF Files in C#, VB.NET](https://www.syncfusion.com/blogs/post/7-ways-to-compress-pdf-files.aspx)
