How to Use IronPdfEngine
IronPdfEngine is a gRPC server crafted to oversee a range of IronPDF tasks, encompassing the creation, editing, and reading of PDF documents.
How to Use IronPdfEngine in Node.js
- Install the Node.js library to utilize IronPdfEngine.
- Include the library by installing it using npm.
- Get the Chrome binary via the same installation.
- Check the version needed by accessing the `ironPdfEngineVersion` property.
- Use the IronPdfEngine to render HTML to PDF with an identical to Chrome renderer.
Get started with IronPDF
IronPdf Node.js and IronPdfEngine
IronPdf for Node.js requires IronPdfEngine to run. The Node.js code is just an API mask over the IronPdfEngine gRPC. So when you call any method in IronPdf for Node.js, the magic happens inside IronPdfEngine!
By default, IronPdf for Node.js will spawn IronPdfEngine as a subprocess and communicate with it until your application shuts down.
Note: Each version of IronPdf for Node.js requires a specific version of IronPdfEngine. Cross-versions are not supported.
IronPdf for Node.js with Local IronPdfEngine
Option 1: Download IronPdfEngine at runtime
By default, after you install IronPdf in your JavaScript project, on the first run, IronPdf will detect your platform (e.g., Windows x64) and download the correct IronPdfEngine binaries from the internet.
npm install @ironsoftware/ironpdf
npm install @ironsoftware/ironpdf
Pros:
- Your application package will be small.
- Can deploy on many platforms.
Cons:
- Internet access is needed on the first few runs.
- Slow startup time.
Option 2 (recommended): Install IronPdfEngine as a dependency
IronPdf for Node.js allows you to add IronPdfEngine as a dependency. These IronPdfEngine dependencies bundle IronPdfEngine to a .zip
file and will extract and use it automatically.
You may choose to install one or multiple of these IronPdfEngine dependencies.
Note: ironpdf
and ironpdf-engine-xxx-xxx
dependency versions must be the same. The ironpdf-engine-xxx-xxx
dependency version does not refer to the version of IronPdfEngine inside.
Platform-Specific Installation:
Windows x64:
npm install @ironsoftware/ironpdf-engine-windows-x64
npm install @ironsoftware/ironpdf-engine-windows-x64
SHELLWindows x86:
npm install @ironsoftware/ironpdf-engine-windows-x86
npm install @ironsoftware/ironpdf-engine-windows-x86
SHELLLinux x64:
npm install @ironsoftware/ironpdf-engine-linux-x64
npm install @ironsoftware/ironpdf-engine-linux-x64
SHELLmacOS x64:
npm install @ironsoftware/ironpdf-engine-macos-x64
npm install @ironsoftware/ironpdf-engine-macos-x64
SHELL- macOS arm:
npm install @ironsoftware/ironpdf-engine-macos-arm64
npm install @ironsoftware/ironpdf-engine-macos-arm64
SHELL
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 Node.js with Remote IronPdfEngine
To use a remote IronPdfEngine, a specific version of IronPdfEngine is needed. For example, if IronPdf for Node.js version 2024.2.2 requires IronPdfEngine version 2024.2.2, do not use IronPdfEngine version 2024.2.1. Access the ironPdfEngineVersion
property to check the version needed.
const ironPdfEngineVersion = IronPdfGlobalConfig.ironPdfEngineVersion;
const ironPdfEngineVersion = IronPdfGlobalConfig.ironPdfEngineVersion;
How to connect
Assume that IronPdfEngine runs remotely at 123.456.7.8:33350
.
Refer to "How to Pull and Run IronPdfEngine".
To connect, you simply need to specify where IronPdfEngine is located (ensure the address is accessible, not blocked by a firewall). Add this code at the initial stage of your application, or just before calling any IronPdf method.
IronPdfGlobalConfig.setConfig({
ironPdfEngineDockerAddress: "123.456.7.8:33350"
});
IronPdfGlobalConfig.setConfig({
ironPdfEngineDockerAddress: "123.456.7.8:33350"
});
Simple as that! After this, your application will be connected to a 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 used for in Node.js?
IronPdfEngine is a gRPC server used in Node.js to manage PDF tasks such as creation, editing, and rendering, offering a seamless PDF handling experience.
How can I install IronPDF for Node.js?
You can install IronPDF for Node.js using npm with the command npm install @ironsoftware/ironpdf
.
What are the differences between local and remote setups for IronPdfEngine?
A local setup involves either downloading IronPdfEngine at runtime or installing it as a dependency, offering faster startup times. A remote setup connects to a remotely hosted IronPdfEngine, eliminating the need for local installations.
How do I ensure compatibility between IronPdf and IronPdfEngine versions?
Each version of IronPdf for Node.js requires a specific version of IronPdfEngine. Use the ironPdfEngineVersion
property to check the required version and ensure both versions match.
What are the benefits of installing IronPdfEngine as a dependency?
Installing IronPdfEngine as a dependency results in faster startup times and eliminates the need for internet access after installation, although it increases the application package size.
How do I connect to a remote IronPdfEngine?
To connect to a remote IronPdfEngine, use IronPdfGlobalConfig.setConfig
to specify the server address, ensuring it's accessible and not blocked by a firewall.
Is internet access required for runtime downloads of IronPdfEngine?
Yes, internet access is required on the first few runs when downloading IronPdfEngine at runtime, which also results in slower startup times.
Do I need to install IronPdfEngine for remote usage?
No, when using a remote IronPdfEngine, you do not need to install it locally as a dependency.
Can IronPdfEngine be used on different platforms?
Yes, IronPdfEngine can be deployed on multiple platforms. Platform-specific npm commands are available for installations on Windows, Linux, and macOS.