JavaでPDFファイルを印刷する方法

Darrius Serrant
Darrius Serrant
2024年10月21日
更新済み 2024年12月17日
共有:
This article was translated from English: Does it need improvement?
Translated
View the article in English

JavaアプリケーションからプログラムによってPDFを印刷することにより、ドキュメントの処理を自動化し、印刷機能をシームレスに統合することができます。 IronPDF for Javaを使用すると、PDFを物理的なプリンターに直接送信でき、コピー数やページ範囲などの印刷設定を正確に制御できます。 このガイドでは、Javaアプリケーション内で印刷タスクを効率化するためにIronPDFの機能を使用する方法を説明します。

Print PDF

The first step is to load the PDF document you want to print. The print method opens the standard print dialog, allowing you to select the printer, page range, and other options before printing. Here's an example: javaimport com.ironsoftware.ironpdf.License;import com.ironsoftware.ironpdf.PdfDocument; License.setLicenseKey("IRONPDF-MYLICENSE-KEY-1EF01"); // Render HTML to PDFPdfDocument pdf = PdfDocument.renderHtmlAsPdf("<h1>テスト</h1>"); // Print with Dialogpdf.print(); You will be prompted with a print dialog to select the printer and options, as shown below. Print Dialog


Print PDF without the Print Dialog

The printWithoutDialog method bypasses the print dialog and sends the document straight to the default printer. This is useful in automation scenarios where no user interaction is needed. javaimport com.ironsoftware.ironpdf.License;import com.ironsoftware.ironpdf.PdfDocument; License.setLicenseKey("IRONPDF-MYLICENSE-KEY-1EF01"); // Render HTML to PDFPdfDocument pdf = PdfDocument.renderHtmlAsPdf("<h1>テスト</h1>"); // Print without Dialogpdf.printWithoutDialog();

Darrius Serrant
フルスタックソフトウェアエンジニア(WebOps)

Darrius Serrantは、マイアミ大学でコンピュータサイエンスの学士号を取得しており、Iron SoftwareでフルスタックWebOpsマーケティングエンジニアとして働いています。若い頃からコーディングに魅了され、コンピューティングを神秘的でありながらアクセスしやすいものと見なし、それが創造性と問題解決のための完璧な媒体であると感じました。

Iron Softwareでは、新しいものを作り出し、複雑な概念を簡単にすることでより理解しやすくすることを楽しんでいます。彼は常駐の開発者の一人として、学生に教えることを志願し、自分の専門知識を次世代と共有しています。

Darriusにとって、彼の仕事は評価され、実際に影響があることで充実しています。