IRONSOFTWAREHOME
Read PDF Files in C#
using IronPdf;
using IronSoftware.Drawing;
using System.Collections.Generic;

// Extracting Image and Text content from Pdf Documents

// open a 128 bit encrypted PDF
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");

// Get all text to put in a search index
string text = pdf.ExtractAllText();

// Get all Images
var allImages = pdf.ExtractAllImages();

// Or even find the precise text and images for each page in the document
for (var index = 0 ; index < pdf.PageCount ; index++)
{
    int pageNumber = index + 1;
    text = pdf.ExtractTextFromPage(index);
    List<AnyBitmap> images = pdf.ExtractBitmapsFromPage(index);
    //...
}
Imports IronPdf
Imports IronSoftware.Drawing
Imports System.Collections.Generic

' Extracting Image and Text content from Pdf Documents

' open a 128 bit encrypted PDF
Dim pdf = PdfDocument.FromFile("encrypted.pdf", "password")

' Get all text to put in a search index
Dim text As String = pdf.ExtractAllText()

' Get all Images
Dim allImages = pdf.ExtractAllImages()

' Or even find the precise text and images for each page in the document
For index As Integer = 0 To pdf.PageCount - 1
    Dim pageNumber As Integer = index + 1
    text = pdf.ExtractTextFromPage(index)
    Dim images As List(Of AnyBitmap) = pdf.ExtractBitmapsFromPage(index)
    '...
Next
NuGet Download
Install-Package IronPdf
Read PDF Files in C#

Read PDF Files in C#

The PdfDocument.ExtractAllText method from the IronPDF C# PDF library is perfect for vanilla PDF text reading tasks. This method handles whitespace and encoding discrepancies within source PDF documents without any issue.

PdfDocument.ExtractTextFromPage reads the text from specific pages of a PDF. In the example below, we see it used iteratively to retrieve text content from a specific range of pages.

IronPDF can also extract raw images from PDFs. For this, use either of the methods from the PdfDocument class below:

  • ExtractAllImages: returns all images embedded in a PDF as IronSoftware.Drawing.AnyBitmap objects.
  • ExtractAllRawImages: retrieves all embedded images as a list of raw bytes (byte[]).
  • ExtractImagesFromPage: extracts the images contained on an indexed page.
  • ExtractImagesFromPages: same as ExtractImagesFromPage, but from a specific page range or a list of individual pages.
  • ExtractRawImagesFromPage and ExtractRawImagesFromPages: works the same as the previous two methods, but returns extracted images as byte arrays instead of as IronSoftware.Drawing.AnyBitmap objects.

Learn more about ExtractTextFromPage Method
View on GitHub

Ready to Get Started?

Nuget Downloads 20,389,208Version:2026.8just released

Key in blue circle

Get your free 30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge related to IronPDF Product Demo

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required