List of Exercises

Read Text of PDF File in WinForms C#

	    
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Read_PDF_File
{
  public partial class Form1 : Form
  {
    // NuGet\Install-Package FreeSpire.PDF -Version 5.1.0
    // https://youtu.be/TO6b5vGiY-A
    public Form1()
    {
      InitializeComponent();
    }

    private void read_pdf_Click(object sender, EventArgs e)
    {
      using (OpenFileDialog ofd = new OpenFileDialog() { Filter = @"PDF File|*.pdf" })
      {
        if (ofd.ShowDialog() == DialogResult.OK)
        {
          // This library has been limited to pdf file with less than 10 pages.
          Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
          doc.LoadFromFile(ofd.FileName);

          StringBuilder buffer = new StringBuilder();

          foreach (Spire.Pdf.PdfPageBase page in doc.Pages)
          {
            buffer.Append(page.ExtractText());
          }

          doc.Close();
          richTextBox1.Text = buffer.ToString();

        }
      }
    }
  }
}
		
	 


Download the project of Visual Studio 2013 in DropBox Download


How to Read Content of PDF File as Text in C# Winforms


Video Thumbnail