How to Extract Text from PDF in C# & VB.NET 

How to extract text from PDF file and how to convert PDF to txt file in C# & VB.NET windows and ASP.NET web projects.

 

Development Environment 

CnetSDK .NET PDF Text Extractor & Converter SDK can be easily integrated into .NET applications development that is development in the environment of x86 & x64 systems, Windows XP & above, .NET Framework 2.0 & above, and Visual Studio 2005 & above. This robust PDF text extractor and converter library is available for C# & VB.NET Class Library, .NET Windows Forms, ASP.NET web, Console application, etc.


Please Note: The free demo project provided here is for .NET Framework 4.0, x86 and x64. Certainly, CnetSDK full free trial package contains all dll libraries for .NET Framework 2.0 and above versions, x86 and x64. You may download CnetSDK .NET PDF to Text Converter free trial here and text more.

 

Main Features Supported

If you are searching for a .NET library/control/component for PDF text extraction or PDF to text conversion, you can directly have a try with CnetSDK .NET PDF text extractor and PDF converter SDK. It enables C# and VB programmers to easily extract text from PDF file and convert PDF to text file (.txt) using C# & VB.NET programming languages. This .NET PDF processing library is applied independently. No other .NET assemblies or software are needed for your .NET windows or web applications development. Main features are listed below.

 

Convert PDF to Text & Extract Text from PDF C# 

The following two pieces of C# sample codes illustrates how to extract text from PDF file and how to convert PDF to text file (.txt).

C#
编辑脚本|Remove
namespace ExtractTextfromPDF 
{ 
  class Program 
  { 
    static void Main(string[] args) 
    { 
      // Create an instance of PDF text extractor object. 
      CSPdfExtractor PDFTextExtractor = new CSPdfExtractor(); 
 
      // Load a PDF from a local file. 
      PDFTextExtractor.LoadPdfFile("F:/Test.pdf"); 
 
      // Get the total page count of the PDF file. 
      int Count = PDFTextExtractor.FilePageCount; 
  
      for (int i = 0; i < Count; i++) 
      { 
         // Extract text from each PDF page. 
         string PdfPageText = PDFTextExtractor.ConvertToText(i); 
         Console.WriteLine(PdfPageText); 
      } 
         Console.ReadKey(); 
  
      // Extract text from whole PDF file. 
      // string AllText = PDFTextExtractor.ConvertToText(); 
      // Console.WriteLine(AllText); 
    } 
  } 
} 
 
 
 
namespace ConvertPDFtoText 
{ 
  class Program 
  { 
    static void Main(string[] args) 
    { 
      // Create an instance of PDF to text converter object. 
      CSPdfExtractor ConvertPDFtoText = new CSPdfExtractor(); 
 
      // Load a PDF from a local file. 
      ConvertPDFtoText.LoadPdfFile("F:/Test.pdf"); 
 
      // Convert PDF to txt file. 
      ConvertPDFtoText.ConvertToTextFile("F:/Test.txt"); 
    } 
  } 
}

More Related 

Click to see more related articles about CnetSDK .NET PDF Text Extractor & Converter SDK.

Support Email: support@cnetsdk.com