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起