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 the purpose of the gRPC server mentioned?
IronPdfEngine is a gRPC server designed to manage various tasks related to PDF documents, such as creation, editing, and reading using IronPDF.
How do I install the Node.js library for PDF management?
You can install IronPdf for Node.js using npm with the command `npm install @ironsoftware/ironpdf`.
What are the pros and cons of downloading the server components at runtime?
Pros: Your application package will be small and can deploy on many platforms. Cons: Internet access is needed on the first few runs and it has a slow startup time with IronPDF.
How can I install server components as a dependency?
You can install IronPdfEngine as a dependency by using npm commands specific to your platform, such as `npm install @ironsoftware/ironpdf-engine-windows-x64` for Windows x64.
Why should the versions of the library and server components match?
Each version of IronPdf for Node.js requires a specific version of IronPdfEngine, and cross-versions are not supported to ensure compatibility.
What is the advantage of installing server components as a dependency?
The main advantage is a faster startup time, and there is no need for internet access after the dependency is installed with IronPDF.
How do I connect to a remote server for PDF tasks?
To connect to a remote IronPdfEngine, specify the server address using `IronPdfGlobalConfig.setConfig`, ensuring the address is accessible and not blocked by a firewall.
Do I need to install server components as a dependency for remote usage?
No, for remote IronPdfEngine usage, installing it as a dependency is not needed.
What is the purpose of the version-checking property?
The `ironPdfEngineVersion` property helps you check the specific version of IronPdfEngine required for your version of IronPdf for Node.js.