Read text from PDF documents in C# and VB.NET

With GemBox.Pdf, you can read text from PDF documents in your C# or VB.NET application.

The following example demonstrates how to read text from a PDF document.

Screenshot
PDF Library for C# / VB.NET Screenshot

See the full code below, use Run Example to execute.

Upload your file(Drag files here)

Download an input file

using System;
using System.IO;
using System.Text;
using GemBox.Pdf;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        PdfDocument document = PdfDocument.Load("Reading.pdf");

        StringBuilder sb = new StringBuilder();

        // Enumerate all pages and append a Unicode text contained in the page content.
        foreach (var page in document.Pages)
            sb.AppendLine(page.Content.ToString());

        document.Close();
        Console.WriteLine(sb.ToString());
    }
}
Imports System.IO
Imports System.Text
Imports GemBox.Pdf

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim document As PdfDocument = PdfDocument.Load("Reading.pdf")

        Dim sb As New StringBuilder()

        ' Enumerate all pages and append a Unicode text contained in the page content.
        For Each page As PdfPage In document.Pages
            sb.AppendLine(page.Content.ToString())
        Next

        document.Close()
        Console.WriteLine(sb.ToString())

    End Sub

End Module