IRONSOFTWAREHOME
USING IRONPDF

How to Read PDF Files in C#

Curtis Chau
Curtis Chau
Updated: April 21, 2026

Programmatic PDF processing is crucial in industries like finance, healthcare, legal, and education, where critical information needs to be processed, analyzed, and extracted from PDF documents for purposes such as data analysis, document management, and automation. Despite its importance, this task can be challenging.

IronPDF: A C# PDF Library

IronPDF enables you to handle incredibly difficult tasks easily. It allows for the easy editing of text in a PDF document, in a similar way to how you can work with text files in a text document, all the while allowing you to export files in any operating system. The IronPDF application covers the complete process of viewing, modifying, and extracting content from a PDF.

Take the Right Step with IronPDF

Text can be read and written in PDF file format quickly and easily using any computer with IronPDF software. Installation is a simple task. This is the best way to learn to read PDF files in C#. You may also download IronPDF free of cost for development. If you explore IronPDF you will notice that the library provides extensive functionality that makes it very easy to use PDFs. Explore classes in your free time! There are several C# examples using HTML to create a PDF available to learn how to create an optimal output from reading PDFs.

Read PDF Files using IronPDF

Step 1: Install the IronPDF Package

To begin, you will need to install the IronPDF NuGet package into your .NET project. You can do this by opening the Package Manager Console in Visual Studio and entering the following command:

PM > Install-Package IronPdf

Step 2: Import the IronPDF Library

Next, you need to import the IronPDF library into your code by adding the following statement at the top of your file:

using IronPdf;

Step 3: Load the PDF Document

Once you have imported the IronPDF library, you can load a PDF document into your code by using the following code:

// Load the PDF document from file path
PdfDocument pdf = PdfDocument.FromFile(@"C:\dotnet.pdf");

// Define the output path for the saved PDF
var outputPath = "Example.pdf";

// Save the PDF document to the specified output path
pdf.SaveAs(outputPath);

Step 4: Extract Text from the PDF

IronPDF provides a range of methods to extract text from an existing PDF file. For example, you can begin extracting text from a PDF and print it on the console by using the following code snippet:

// Extract text from the loaded PDF document
string text = pdf.ExtractText();

// Print the extracted text to the console
Console.WriteLine(text);

Using the above code, you can extract text from a PDF file.

How to Read PDF Files in C#, Figure 1: Extracting Text from a PDF Using IronPDF Extracting Text from a PDF Using IronPDF

Step 5: Rasterize a PDF to Images

Let's rasterize the PDF file to Images with IronPDF using IronPDF. First, import the required libraries:

using System.Linq;
using IronPdf;
using IronSoftware.Drawing;

The code then uses the RasterizeToImageFiles method to extract all the pages of the PDF document to a folder as image files. The extracted images can be saved as either PNG or JPG files, and the dimensions and page ranges of the images can also be specified.

// Extract all pages to a folder as image files with PNG format
pdf.RasterizeToImageFiles(@"C:\image\folder\*.png");

// Extract all pages to JPG images with specified dimensions
pdf.RasterizeToImageFiles(@"C:\image\folder\example_pdf_image_*.jpg", 100, 80);

Finally, the code uses the ToBitmap method to extract all pages of the PDF document as AnyBitmap objects, which can be processed and manipulated further within the code.

// Extract all pages as AnyBitmap objects for further processing
AnyBitmap[] pdfBitmaps = pdf.ToBitmap();

The above code demonstrates how to extract the contents of a PDF file using IronPDF and save the extracted data as image files or AnyBitmap objects for further processing.

Step 7: Manipulate PDF Pages

Let's learn how to manipulate the pages of a PDF document by working with IronPDF.

The code first removes pages two and three from the PDF document using the RemovePages method:

// Remove pages two and three from the PDF document
pdf.RemovePages(1, 2);

The RemovePages method takes two arguments: the starting page to remove (in this case, page 2, represented as 1 since page numbering starts at 0) and the number of pages to remove (in this case, 2 pages).

Step 6: Save the PDF

Finally, you can save the PDF file to your local system using the SaveAs method. The code for saving the PDF file is as follows:

// Save the PDF document to a specified output path
pdf.SaveAs(outputPath);

IronPDF Compatibility

IronPDF is highly compatible with all the latest .NET Frameworks including the .NET 7. It also supports .NET Blazor and .NET MAUI, which are the latest offerings from Microsoft for web development. The library's compatibility with these frameworks makes it possible for developers to seamlessly integrate IronPDF into their applications and take advantage of its powerful features.

One of the main features of IronPDF is its ability to read PDF files in .NET Blazor and .NET MAUI. This feature enables developers to quickly and easily read and extract data from PDF files and use them in the .NET applications. This capability can be especially helpful when working with a large volume of data. Developers don't need any other library to use the IronPDF in their .NET project.

Get more information about IronPDF working with .NET Blazor in this tutorial and learn about integrating IronPDF with .NET MAUI on IronPDF's website.

Conclusion

In conclusion, reading PDF files programmatically is crucial in various industries. IronPDF provides a comprehensive solution to handle this task by offering extensive functionality to read, modify, and extract content from a PDF file. IronPDF is easy to install and use with just a few simple steps.

The library offers methods to extract text from PDF documents, rasterize a PDF to an image, manipulate pages, and save PDF files. Whether you are new to programmatic PDF processing or an experienced developer, IronPDF is the perfect tool to take your skills to the next level.

If you are looking for a reliable and efficient solution for reading PDF files in C#, IronPDF is worth exploring, especially with its license options and pricing information, and a free trial available. You can see more plans provided by IronPDF in the image below. You can select the package that matches your needs.

IronPDF Licensing Prices

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Related Articles

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • 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

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