A scanned PDF file is basically one or more flat images captured by a scanner or a camera. You cannot copy, paste, or process information from such files. This article covers how to convert a scanned PDF to text in C#.
- Scanned PDF to Text Converter – C# API Installation
- Convert Scanned PDF to Text String in C#
- Convert Scanned PDF to TXT File Programmatically in C#
Scanned PDF to Text Converter – C# API Installation
Aspose.OCR for .NET API is used to perform OCR operations. It can recognize the characters optically from images or scanned PDF documents. Please configure the API by downloading the DLL file from the New Releases section, or with the following NuGet installation command.
PM> Install-Package Aspose.OCR
Convert Scanned PDF to Text String in C#
You can convert a scanned PDF file to a text string by performing OCR operations on it. You need to follow the steps below to print the text from a scanned PDF document:
- Specify the setting for recognizing the scanned PDF file.
- Initialize AsposeOcr class instance.
- Initialize RecognitionResult class object.
- Print the text after recognizing it from scanned PDF.
The following code snippet shows how to recognize text from scanned PDF in C#:
Convert Scanned PDF to TXT File Programmatically in C#
You can convert a scanned PDF file to a TXT file with the following steps:
- Instantiate AsposeOcr class object.
- Create DocumentRecognitionSettings class object.
- Save recognition results and initialize StringBuilder class instance.
- Save the result in a TXT file.
The code snippet below explains how to convert a scanned PDF file to a TXT file programmatically in C#:
Get Free Evaluation License
You can request a free evaluation license to test the API in its full capacity.
Conclusion
In this article, you have learned how to convert scanned PDF to a text string or a text file programmatically using C#. Moreover, you may check several other features of the API by visiting the documentation. Please feel free to contact us at the forum in case of any concerns.