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 Host
- Utilize the setIronPdfEnginePort method to configure Port
- Use the IronPdfEngine to render HTML to PDF with an identical to Chrome renderer
{Link to Download IronPDF for Java on ironpdf.com}
IronPdf for Java and IronPdfEngine
IronPdf for Java requires IronPdfEngine to run. The Java code is just an API mask over IronPdfEngine gRPC. So when you call any method in IronPdf for Java, the magic will happen inside IronPdfEngine!
By default, IronPdf for Java will spawn IronPdfEngine as a subprocess and talk to it until your application shuts down.
Please note
IronPdf for Java with Local IronPdfEngine
Option 1: Download IronPdfEngine at Runtime
By default, after you install IronPdf in your Java project, on the first run, IronPdf will detect your platform (e.g., Windows x64) and download the correct IronPdfEngine binaries from the internet.
<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 as a dependency. These IronPdfEngine dependencies bundle IronPdfEngine to a .zip file and will extract and use automatically.
You may choose to install one or multiple of these IronPdfEngine dependencies.
Please note
ironpdf
and ironpdf-engine-xxx-xxx
dependency version must be the same.ironpdf-engine-xxx-xxx
dependency version does not refer to the version of IronPdfEngine inside.
For Windows x64
<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>
For Linux x64
<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>
For macOS arm
<dependency>
<groupId>com.ironsoftware</groupId>
<artifactId>ironpdf-engine-macos-arm64</artifactId>
<version>20xx.xx.xxxx</version>
</dependency>
Please note
Pros
- Faster startup time.
- Internet access is not needed after the dependency is installed.
Cons
- Your application package will be large.
- Need to specify the target platforms.
IronPdf for Java with Remote IronPdfEngine
To use remote IronPdfEngine, a specific version of IronPdfEngine is needed. For example, if IronPdf for Java version 2024.2.2 requires IronPdfEngine version 2024.2.2, do not use IronPdfEngine version 2024.2.1. Use the getIronPdfEngineVersion
method to check for the version needed.
String ironPdfEngineVersion = Settings.getIronPdfEngineVersion();
How to Connect
Assume that IronPdfEngine is up and running remotely at 123.456.7.8:33350
Refer to Instructions on How to Pull and Run IronPdfEngine
You just need to tell IronPdf where IronPdfEngine is (please make sure that address is accessible, not blocked by the firewall). Add this code at the initial stage of your application (or just before calling any IronPdf method).
com.ironsoftware.ironpdf.Settings.setIronPdfEngineHost("123.456.7.8");
com.ironsoftware.ironpdf.Settings.setIronPdfEnginePort(33350);
Simple as that! After this, your application will be connected 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."