IRONSOFTWAREHOME
PDFを画像にラスター化する

import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.edit.PageSelection;
import com.ironsoftware.ironpdf.image.ToImageOptions;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.List;

PdfDocument pdf = PdfDocument.fromFile(Paths.get("assets/composite.pdf"));

// Extract all the pages from the PDF file.
List<BufferedImage> extractedImages = pdf.toBufferedImages();

// With the ToImageOptions object, specify maximum image dimensions for each
// extracted image, as well as their DPI
ToImageOptions rasterOptions = new ToImageOptions();
rasterOptions.setImageMaxHeight(100);
rasterOptions.setImageMaxWidth(100);

// Call the toBufferedImage method along with a PageSelection object to choose the pages from which to
// extract the images
//
// Available PageSelection methods include: allPages, lastPage, firstPage, singlePage(int pageIndex),
// and pageRange(int startingPage, int endingPage)
List<BufferedImage> sizedExtractedImages = pdf.toBufferedImages(rasterOptions, PageSelection.allPages());

// Save all the extracted images to a file location
int i = 1;
for (BufferedImage extractedImage : sizedExtractedImages) {
    String fileName = "assets/images/" + i++ + ".png";
    ImageIO.write(extractedImage, "PNG", new File(fileName));
}
mvn install
PDFを画像にラスター化する

PDFを画像にラスター化する

ファイルからロードされた後、ソースコンテンツ(ウェブページ、URL、HTMLなど)から変換されたIronPDFは、ネットワークを介して送信するなどの用途で、ファイルシステムに保存、データベースに格納、または送信するためにPDFドキュメントのページを画像にエクスポートできます。

toBufferedImages メソッドは List を返し、BufferedImage オブジェクトのコレクションを含みます。 各 BufferedImage には、元の PdfDocument の単一ページ用の画像バイトコンテンツが含まれています。 さらに、BufferedImage List はページ番号順に昇順に配置されています。 開発者は、この List を PDF 内のページの包括的なセットに対して生成するために、メソッド呼び出しの引数として PageSelection オブジェクトを含めることができます。

注目のコード例は、変換後の画像の期待される幅と高さを設定するために ToImageOptions オブジェクトを作成します。 このクラスには、画像出力のDPIを変更するメソッドも含まれています (setDpi)。 開発者は、このクラスのインスタンスと PageSelection のインスタンスを一緒に組み合わせて、PDFから画像への変換のスコープ、サイズ、品質を同時に制御することができます。

IronPDFとその機能に関する追加情報は、IronPDF Documentation and Resourcesをご覧ください。

Learn more about the toBufferedImages method here.
GitHubで見る

準備はできましたか?

バージョン:2026.6リリースされたばかり

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

世界中の数百万人のエンジニアから信頼されています。

ライセンスはより安く
義務のない相談を受ける
下記のフォームを記入するか、sales@ironsoftware.comにメールしてください。
あなたの詳細は常に守秘されます。
世界中の数百万人のエンジニアから信頼されています。
ライセンスはより安く
あなたの無料30日間の試用キーをすぐに入手。
クレジットカードやアカウントの作成は不要です。
PDFのため for Java Mavenライブラリ
Mavenでインストール

バージョン: 2026.6

<dependency>
   <groupId>com.ironsoftware</groupId>
   <artifactId>ironpdf</artifactId>
   <version>2026.6.1</version>
</dependency>
https://central.sonatype.com/artifact/com.ironsoftware/ironpdf/2026.6.1
or
Java PDF JAR
JAR をダウンロード

バージョン: 2026.6

Manually install into your project