Extract text from PDF in C#

Do you need to extract text from PDF? Programmatic modification of PDF documents is an essential part of modern digital workflows. With .NET libraries like Aspose.PDF, developers can extract text from PDF. These libraries are stand-alone solutions that don’t rely on other software and are ready for commercial use. They cover all possible needs of professional C# developers.

In order to extract text from PDF file, we’ll use Aspose.PDF for .NET API which is a feature-rich, powerful and easy to use document manipulation API for net platform. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.

Package Manager Console

PM > Install-Package Aspose.PDF

Extract text from PDF in C#

To try the code in your environment, you need Aspose.PDF for .NET.

  1. Load the PDF with an instance of Document.
  2. Create TextAbsorber object to extract text.
  3. Accept the absorber for all the pages.
  4. Get the extracted text
  5. Create a writer and open the file, write a line of text to the file