Convert PDF to TXT in C#
Perform optical character recognition on PDF document and save text as PDF document using Aspose.OCR for .NET library.
How to convert PDF to TXT using C#
Aspose.OCR for .NET is a powerful yet easy-to-use and cost-effective library for converting PDF images to TXT documents. Supporting 26 languages based on Latin, Cyrillic and Chinese, its state-of-the-art optical character recognition engine provides superior recognition speed and accuracy, while isolating you from formulas, neural networks, and other complex technical details. It allows you to add OCR functionality to your .NET applications in less than 10 lines of code.
processes scanned images or even smartphone photos in PDF format and creates PDF documents containing recognized text. To add it to your project, you just need to install the Aspose.OCR
package in your project with the following command:
Package Manager Console Command
PM> Install-Package Aspose.OCR
Steps to Convert PDF to TXT
With .NET OCR and just a few lines of code, you can create full-featured application that converts an PDF image to TXT document:
- Create an instance of AsposeOcr class
- Call AsposeOCR.RecognizeImage method
- Pass the PDF file path as parameter
- AsposeOCR.RecognizeImage returns a String or file of TXT type
Before running the example, make sure that .NET API compatible with NET Standard 2.0 specification is installed on your system and all external dependencies of Aspose.OCR package are referenced in your project.
- NET Standard 2.0+ compatible solution
- Aspose.OCR for .NET referenced in your project.
This sample code shows PDF to TXT .NET Conversion
// initialize an instance of AsposeOcr AsposeOcr ocr = new AsposeOcr(); // recognize image string riText = ocr.RecognizeImage("template.PDF"); // print text File. File.WriteAllText("document.TXT", riText);
PDF What is PDF File Format
Portable Document Format (PDF) is a type of document created by Adobe back in 1990s. The purpose of this file format was to introduce a standard for representation of documents and other reference material in a format that is independent of application software, hardware as well as Operating System. The PDF file format has full capability to contain information like text, images, hyperlinks, form-fields, rich media, digital signatures, attachments, metadata, Geospatial features and 3D objects in it that can become as part of source document.Read More
TXT What is TXT File Format
A file with .TXT extension represents a text document that contains plain text in the form of lines. Paragraphs in a text document are recognized by carriage returns and are used for better arrangement of file contents. A standard text document can be opened in any text editor or word processing application on different operating systems. All the text contained in such a file is in human-readable format and represented by sequence of characters.Read More
Other Supported Conversions
Using C#, one can easily convert different formats including.