C# で PDF を読み込む手順
今日は、PDFコンテンツを読み取り、元の形式でテキストを抽出するための簡単な方法について説明します。 これは、C#プロジェクト内でドキュメント全体または特定のページに対して行うことができます。



IronPDFを始めましょう
今日から無料トライアルでIronPDFをあなたのプロジェクトで使い始めましょう。
C#でPDFファイルを読み取る方法
- PDF 読み書きのための IronPDF C# ライブラリをダウンロードする
- でインストール NuGet経由のIronPdf ライブラリをテストする
- PDFファイルを読み込み、コンテンツを抽出し、高品質かつオリジナルの画像を抽出します。
- C#フォームを使用して、PDFコンテンツを読んだときの完璧な出力を表示します。
- PDF出力を表示
C#でPDFファイルを読む
このC#ライブラリを使用すると、PDFファイルを読み取り、コンテンツを抽出し、さらに高品質でオリジナルの画像を抽出することができます。 以下の例を参照して、.NET環境でPDF閲覧のニーズを満たすためにさまざまな関数を使用する方法をご確認ください。
:path=/static-assets/pdf/content-code-examples/how-to/csharp-read-pdf-read-pdf.cs
using IronPdf;
using IronSoftware.Drawing;
using System.Collections.Generic;
// Select the desired PDF File
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");
// Extract all text from an pdf
string allText = pdf.ExtractAllText();
// Get all Images
IEnumerable<AnyBitmap> AllImages = pdf.ExtractAllImages();
// Else combine above both functionality using PageCount
for (var index = 0; index < pdf.PageCount; index++)
{
string Text = pdf.ExtractTextFromPage(index);
IEnumerable<AnyBitmap> Images = pdf.ExtractImagesFromPage(index);
}
Imports IronPdf
Imports IronSoftware.Drawing
Imports System.Collections.Generic
' Select the desired PDF File
Private pdf As PdfDocument = PdfDocument.FromFile("sample.pdf")
' Extract all text from an pdf
Private allText As String = pdf.ExtractAllText()
' Get all Images
Private AllImages As IEnumerable(Of AnyBitmap) = pdf.ExtractAllImages()
' Else combine above both functionality using PageCount
For index = 0 To pdf.PageCount - 1
Dim Text As String = pdf.ExtractTextFromPage(index)
Dim Images As IEnumerable(Of AnyBitmap) = pdf.ExtractImagesFromPage(index)
Next index
出力
C#フォームを使用してPDFコンテンツの読み取り結果を完璧に表示する方法を示しました。 このアプローチでは、できるだけ少ないコードでプロジェクトのニーズを達成するというシンプルさが重要です。