Introduction: Reading Contents From PDF In C#

In this post, we will learn about Reading Contents From PDF In C# with an example.

Reading Contents From PDF In C#

PDF Read

Description:

In my previous posts I have explained various topics like Basics Of Pointers In C#.
Now in this post, I will explain about Reading Contents From PDF In C# with appropriate example.

Create Console Application in Visual Studio and write below code in it.
Here, You will need to add reference to iTextSharp Library, which you can get from NuGet Package Manager.

using System;
using System.Text;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;  

namespace FileRead
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder _Result = new StringBuilder();
            using (PdfReader reader = new PdfReader("D:\\DotNetK.pdf"))//Here specify location of your pdf file
            {
                for (int i = 1; i <= reader.NumberOfPages; i++)
                {
                    _Result.Append(PdfTextExtractor.GetTextFromPage(reader, i));
                }
            }

            Console.Write(_Result.ToString());
            Console.Read();
        }
    }
}



Summary

I hope you got an idea about Reading Contents From PDF In C#.
I would like to have feedback from my blog readers.
I hope after reading this article you will be able to do this.
Your valuable feedback, question, or comments about this article are always welcome.

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website