IronPDF for Java - JavaアプリケーションでPDFを作成、編集、読み取る
IronPDF for Javaについて
IronPDF for Javaは、Iron Softwareによって開発および維持されているライブラリで、ソフトウェアエンジニアがJava 8+、Kotlin、ScalaプロジェクトでPDFコンテンツを作成、編集、および抽出するのを助けます。
IronPDF for Java は、 IronPDF for .NETの成功と人気を基盤としています。
IronPDF for Java は gRPC を使用して IronPdfEngine と通信します。
IronPDFの得意分野
- HTML、URL、JavaScript、CSS、および多くの画像フォーマットからPDFを生成
- ヘッダー/フッター、署名、添付ファイル、パスワードおよびセキュリティの追加
- パフォーマンス最適化: フルマルチスレッドおよび非同期サポート
- その他多数! 私たちのウェブサイトにアクセスして、すべてのコード例や私たちの50以上の機能の完全リストを確認してください。
IronPDF for Javaの使用
IronPDFをJavaの依存関係として定義
pom.xml 依存関係
IronPDF を依存関係として定義するには、pom.xml に以下を追加してください。
<dependencies>
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.3</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.3</version>
</dependency>
</dependencies>
jarファイルのダウンロード
オプションでIronPDF JARファイルを手動でダウンロードしてスタンドアロンで使用することができます。
初回ビルドと実行
IronPdfEngine バイナリは、プロジェクトの初回実行時に自動的にダウンロードされます。IronPdfEngine プロセスは、 IronPDF関数を初めて呼び出したときに開始され、アプリケーションが終了されるかアイドル状態になったときに停止します。
Maven依存関係としてIronPDFエンジンをインストール
IronPdfEngineをMaven依存関係として追加することで、依存関係の読み込み中にバイナリがダウンロードされます:
- このアプローチにより、IronPdfEngineのバイナリがすでにダウンロードされているため、長いスタートアッププロセスを避けることができます。
- さらに、外部ソースからのダウンロードを許可しないデプロイメント設定にも有益です。
マルチプラットフォームアプリで作業している場合は、単純に以下のいずれかまたは複数のコードスニペットをpom.xmlファイルに追加してください:
Windows x64用
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf-engine-windows-x64</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf-engine-windows-x64</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
Windows x86用
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf-engine-windows-x86</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf-engine-windows-x86</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
Linux x64用
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf-engine-linux-x64</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf-engine-linux-x64</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
macOS x64 (Intel)用
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf-engine-macos-x64</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf-engine-macos-x64</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
macOS Arm (Apple Silicon)用
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf-engine-macos-arm64</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf-engine-macos-arm64</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
Javaコードの書き始め
依存関係が定義されたら、Java コードの先頭に import com.ironsoftware.ironpdf.* ステートメントを追加して開始できます。 始めるための簡単なHTMLからPDFへのサンプルはこちらです:
// Import statement for IronPDF Java
import com.ironsoftware.ironpdf.*;
// Apply your license key
License.setLicenseKey("YOUR-LICENSE-KEY");
// Set a log path
Settings.setLogPath(Paths.get("C:/tmp/IronPdfEngine.log"));
// Render the HTML as a PDF. Stored in myPdf as type PdfDocument
PdfDocument myPdf = PdfDocument.renderHtmlAsPdf("<h1> ~Hello World~ </h1> Made with IronPDF!");
// Save the PdfDocument to a file
myPdf.saveAs(Paths.get("html_saved.pdf"));
// Import statement for IronPDF Java
import com.ironsoftware.ironpdf.*;
// Apply your license key
License.setLicenseKey("YOUR-LICENSE-KEY");
// Set a log path
Settings.setLogPath(Paths.get("C:/tmp/IronPdfEngine.log"));
// Render the HTML as a PDF. Stored in myPdf as type PdfDocument
PdfDocument myPdf = PdfDocument.renderHtmlAsPdf("<h1> ~Hello World~ </h1> Made with IronPDF!");
// Save the PdfDocument to a file
myPdf.saveAs(Paths.get("html_saved.pdf"));
これは、URLからPDFへの別の簡単な例です:
// Import statement for IronPDF Java
import com.ironsoftware.ironpdf.*;
// Apply your license key
License.setLicenseKey("YOUR-LICENSE-KEY");
// Set a log path
Settings.setLogPath(Paths.get("C:/tmp/IronPdfEngine.log"));
// Render the URL as a PDF. Stored in myPdf as type PdfDocument
PdfDocument myPdf = PdfDocument.renderUrlAsPdf("https://ironpdf.com/java");
// Save the PdfDocument to a file
myPdf.saveAs(Paths.get("url_saved.pdf"));
// Import statement for IronPDF Java
import com.ironsoftware.ironpdf.*;
// Apply your license key
License.setLicenseKey("YOUR-LICENSE-KEY");
// Set a log path
Settings.setLogPath(Paths.get("C:/tmp/IronPdfEngine.log"));
// Render the URL as a PDF. Stored in myPdf as type PdfDocument
PdfDocument myPdf = PdfDocument.renderUrlAsPdf("https://ironpdf.com/java");
// Save the PdfDocument to a file
myPdf.saveAs(Paths.get("url_saved.pdf"));
完全なMain.java例
package org.example;
// Import statement for IronPDF Java
import com.ironsoftware.ironpdf.*;
import java.io.IOException;
import java.nio.file.Paths;
public class Main {
public static void main(String[] args) throws IOException {
// Apply your license key
License.setLicenseKey("YOUR-LICENSE-KEY");
// Set a log path
Settings.setLogPath(Paths.get("C:/tmp/IronPdfEngine.log"));
// Render the HTML as a PDF. Stored in myPdf as type PdfDocument
PdfDocument myPdf = PdfDocument.renderHtmlAsPdf("<h1> ~Hello World~ </h1> Made with IronPDF!");
// Save the PdfDocument to a file
myPdf.saveAs(Paths.get("html_saved.pdf"));
}
}
package org.example;
// Import statement for IronPDF Java
import com.ironsoftware.ironpdf.*;
import java.io.IOException;
import java.nio.file.Paths;
public class Main {
public static void main(String[] args) throws IOException {
// Apply your license key
License.setLicenseKey("YOUR-LICENSE-KEY");
// Set a log path
Settings.setLogPath(Paths.get("C:/tmp/IronPdfEngine.log"));
// Render the HTML as a PDF. Stored in myPdf as type PdfDocument
PdfDocument myPdf = PdfDocument.renderHtmlAsPdf("<h1> ~Hello World~ </h1> Made with IronPDF!");
// Save the PdfDocument to a file
myPdf.saveAs(Paths.get("html_saved.pdf"));
}
}
さらなる設定情報
注意:すべての設定、ログ、およびライセンス操作は、任意のIronPDFメソッドが呼び出される前に実行される必要があることに注意してください。
ライセンスキーの適用
ライセンスキーを適用するには、以下をメソッドの冒頭に追加してください。
com.ironsoftware.ironpdf.License.setLicenseKey("YOUR-LICENSE-KEY");
com.ironsoftware.ironpdf.License.setLicenseKey("YOUR-LICENSE-KEY");
ロギング
IronPDF Javaは、ロギング目的でslf4jロガーを使用します。 ロギングを有効にするには、次を使用します:
com.ironsoftware.ironpdf.Settings.setDebug(true);
com.ironsoftware.ironpdf.Settings.setDebug(true);
IronPdfEngine ログ パスを指定するには、次を追加します。
com.ironsoftware.ironpdf.Settings.setLogPath(Paths.get("C:/tmp/myIronPdfEngineLog.log"));
com.ironsoftware.ironpdf.Settings.setLogPath(Paths.get("C:/tmp/myIronPdfEngineLog.log"));
ライセンスとサポートの提供
ライブプロジェクトで使用するためにIronPDFのライセンスを購入する。 30日間のトライアルライセンスもトライアルユーザー向けに利用可能です。
完全なコード例、チュートリアル、ライセンス情報、ドキュメントについては、IronPDF for Javaリソースを訪問してください。
さらなるサポートとお問い合わせには、サポートチームに連絡してください。

