IRONSOFTWAREHOME
在 C# 中读取 PDF 文件
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
PM > Install-Package IronPdf
在 C# 中读取 PDF 文件

在 C# 中读取 PDF 文件

IronPDF C# PDF库中的PdfDocument.ExtractAllText方法非常适合处理简单的PDF文本读取任务。 此方法可以处理源 PDF 文档中的空白和编码不一致问题。

PdfDocument.ExtractTextFromPage从PDF的特定页面读取文本。 在下面的示例中,我们看到它被迭代使用以从特定页面范围中获取文本内容。

IronPDF 也可以从 PDF 中提取原始图像。 为此,使用下面PdfDocument类中的任一方法:

  • IronSoftware.Drawing.AnyBitmap对象的形式返回。
  • byte[])。
  • ExtractImagesFromPage:提取索引页面中包含的图像。
  • ExtractImagesFromPage相同,但来源于特定页面范围或单独页面列表。
  • IronSoftware.Drawing.AnyBitmap对象。

Learn more about ExtractTextFromPage Method
在 GitHub 上查看

准备开始了吗?

Nuget Downloads 21,105,021版本:2026.9刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥。

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

OR
bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥。
无需信用卡或创建账户
C# 用于 PDF 的 NuGet 库
通过 NuGet 安装

版本: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. 在解决方案资源管理器中,右键点击引用,管理 NuGet 包
  2. 选择浏览并搜索 “IronPDF”
  3. 选择包并安装
C# PDF DLL
下载 DLL

版本: 2026.9

或在此处下载 Windows 安装程序。

  1. 下载并解压 IronPDF 到您的解决方案目录中的 ~/Libs 之类的位置
  2. 在 Visual Studio 解决方案资源管理器中,右键点击引用。选择浏览,“IronPDF.dll”

$999 起