How to Use IronPdfEngine
IronPdfEngine is a gRPC server designed to manage various IronPDF operations, including creating, writing, editing, and reading PDFs.
How to Use IronPdfEngine as a Remote Server
- Install the Java library to utilize IronPdfEngine
- Include the library in the pom.xml file
- Utilize the `setIronPdfEngineHost` method to configure the host
- Utilize the `setIronPdfEnginePort` method to configure the port
- Use the IronPdfEngine to render HTML to PDF with a renderer identical to Chrome
Link to Download IronPDF for Java on ironpdf.com
IronPdf for Java and IronPdfEngine
IronPdf for Java requires IronPdfEngine to run. The Java code serves as an API mask over IronPdfEngine gRPC. When you invoke any method in IronPdf for Java, the actual processing occurs inside IronPdfEngine!
By default, IronPdf for Java will spawn IronPdfEngine as a subprocess and interact with it until your application shuts down.
IronPdf for Java with Local IronPdfEngine
Option 1: Download IronPdfEngine at Runtime
By default, after you install IronPdf in your Java project, on the initial run, IronPdf will detect your platform (e.g., Windows x64) and download the appropriate IronPdfEngine binaries from the internet.
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf</artifactId>
<version>20xx.xx.xx</version>
</dependency>
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf</artifactId>
<version>20xx.xx.xx</version>
</dependency>
Pros
- Your application package will be small.
- Can deploy on many platforms.
Cons
- Internet access is needed on the first runs.
- Slow startup time.
Option 2 (recommended): Install IronPdfEngine as a Dependency
IronPdf Java allows you to add IronPdfEngine directly as a dependency. These dependencies wrap IronPdfEngine into a .zip file, automatically extracting and using it.
You can choose to install one or more of these IronPdfEngine dependencies.
ironpdf
and ironpdf-engine-xxx-xxx
dependency version must be the same. ironpdf-engine-xxx-xxx
does not refer to the IronPdfEngine's internal version.For 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>
For 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>
For 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>
For macOS x64
<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>
For macOS arm
<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>
Pros
- Faster startup time.
- Internet access is not needed after the dependency is installed.
Cons
- Your application package will be large.
- Need to specify target platforms.
IronPdf for Java with Remote IronPdfEngine
To use a remote IronPdfEngine, a specific version is necessary. For example, if IronPdf for Java version 2024.2.2 requires IronPdfEngine version 2024.2.2, do not use version 2024.2.1. Use the getIronPdfEngineVersion
method to verify the required version.
// Get the version of the IronPdfEngine needed for the current Java version
String ironPdfEngineVersion = Settings.getIronPdfEngineVersion();
// Get the version of the IronPdfEngine needed for the current Java version
String ironPdfEngineVersion = Settings.getIronPdfEngineVersion();
How to Connect
Assume that IronPdfEngine is running remotely at 123.456.7.8:33350
.
Refer to Instructions on How to Pull and Run IronPdfEngine
To connect, specify the location of IronPdfEngine (ensure the address is accessible and not blocked by firewalls). Add this code during the initial stage of your application (or just before invoking any IronPdf method).
// Set the host and port for a remote IronPdfEngine connection
com.ironsoftware.ironpdf.Settings.setIronPdfEngineHost("123.456.7.8");
com.ironsoftware.ironpdf.Settings.setIronPdfEnginePort(33350);
// Set the host and port for a remote IronPdfEngine connection
com.ironsoftware.ironpdf.Settings.setIronPdfEngineHost("123.456.7.8");
com.ironsoftware.ironpdf.Settings.setIronPdfEnginePort(33350);
Simple as that! After executing this code, your application connects to the remote IronPdfEngine!
For remote IronPdfEngine, installing IronPdfEngine as a dependency is not needed. You can skip the section titled "Option 2 (recommended): Install IronPdfEngine as a Dependency."
Frequently Asked Questions
What is IronPdfEngine and how does it relate to Java PDF operations?
IronPdfEngine is a gRPC server that handles PDF operations like creation, editing, and reading. In Java, it functions as the backend for IronPDF, which serves as an API mask over IronPdfEngine.
How can I render HTML to PDF in Java using IronPdfEngine?
You can use the IronPDF library in Java to render HTML into PDFs. The process involves setting up IronPdfEngine and using its methods, such as RenderHtmlAsPdf
, to convert HTML content to PDF format.
Why do Java PDF operations require version compatibility with IronPdfEngine?
Version compatibility is crucial as each version of IronPDF for Java is designed to work with a specific version of IronPdfEngine, ensuring seamless operations and preventing compatibility issues.
What are the advantages of using IronPdfEngine locally in Java projects?
Using IronPdfEngine locally can lead to faster startup times and eliminate the need for internet access post-installation. It allows for more efficient PDF processing directly within the Java application.
How do I configure IronPdfEngine for remote server use in Java?
To configure IronPdfEngine for remote use, set the server's host and port using the setIronPdfEngineHost
and setIronPdfEnginePort
methods in your Java application, ensuring the server is accessible.
What should I consider when deciding to download IronPdfEngine binaries at runtime?
Downloading binaries at runtime results in a smaller application package and cross-platform deployment flexibility. However, it requires internet access initially and may result in slower startup times.
Can IronPdfEngine be used without installing it as a dependency?
Yes, IronPdfEngine can be used without installation as a dependency by downloading the necessary binaries at runtime. This approach is suitable for dynamic environments where application size is a concern.
How do I ensure my Java PDF library is using the correct IronPdfEngine version?
You can verify the IronPdfEngine version required for your Java PDF library by using the getIronPdfEngineVersion
method, ensuring compatibility and proper functionality.
What are the steps to install IronPdfEngine in a Java project?
To install IronPdfEngine, include the IronPDF Java library in your project, configure the server's host and port, and connect to the IronPdfEngine using the appropriate settings within your application code.
Is it necessary to have internet access when using IronPdfEngine in Java?
Internet access is necessary when choosing to download IronPdfEngine binaries at runtime. However, if IronPdfEngine is installed as a dependency, internet access is not required after the initial setup.