Use IronPDF with in-Engine Mode

This article was translated from English: Does it need improvement?
Translated
View the article in English

本地与引擎的区别

IronPDF 有一些性能密集的功能,您可以选择远程运行。 虽然 IronPDF 不需要 IronPdfEngine 运行,但将 IronPdfEngine 设置为远程服务是避免在旧操作系统和移动环境中出现平台特定 Chrome 兼容性问题的可选方法。

开始使用 IronPDF

今天在您的项目中使用 IronPDF,免费试用。

第一步:
green arrow pointer


使用引擎如何改变您与 IronPDF 编码的方式

在使用引擎配置时,我们建议从 NuGet 安装 IronPdf.Slim 而不是完整的 IronPdf 包,因为引擎管理本地包中包含的全部额外负载。

Install-Package IronPdf.Slim

安装 IronPdf.Slim 后,通过指向您的 IronPdfEngine 实例来配置连接设置。 在应用程序的启动时 (或在调用任何 IronPDF 方法之前) 添加以下代码:

要添加到 C# 代码中的额外配置代码行

假设 IronPdfEngine 远程运行在 123.456.7.8:33350

// Establish a connection with the remote IronPdfEngine
// Remember to replace the IP address and port with your actual server details
Installation.ConnectToIronPdfHost(
    IronPdf.GrpcLayer.IronPdfConnectionConfiguration.RemoteServer("123.456.7.8:33350")
);

// Additional code for your application
// Establish a connection with the remote IronPdfEngine
// Remember to replace the IP address and port with your actual server details
Installation.ConnectToIronPdfHost(
    IronPdf.GrpcLayer.IronPdfConnectionConfiguration.RemoteServer("123.456.7.8:33350")
);

// Additional code for your application
' Establish a connection with the remote IronPdfEngine
' Remember to replace the IP address and port with your actual server details
Installation.ConnectToIronPdfHost(IronPdf.GrpcLayer.IronPdfConnectionConfiguration.RemoteServer("123.456.7.8:33350"))

' Additional code for your application
$vbLabelText   $csharpLabel

IronPdfEngine 如何工作?

IronPdfEngine 是一个容器化的服务器,旨在管理各种 IronPDF 操作,包括使用 gRPC 协议创建、写入、编辑和读取 PDF。 作为一个自包含的 C# .NET 应用程序构建,IronPdfEngine 独立运行,消除了在执行过程中对 .NET 运行时的需求。 我们为您处理 gRPC 连接,这样您就可以专注于编码!

有关将 IronPDF 作为自己容器运行的快速入门教程,请参考此教程

class="hsg-featured-snippet">

如何使用 IronPdfEngine 作为远程服务器

  1. 安装 C# 库以利用 IronPdfEngine
  2. 从 NuGet 安装 IronPdf.slim 包
  3. 利用 IronPdfConnectionConfiguration 类配置连接设置
  4. 使用 IronPdfEngine 使用与 Chrome 相同的渲染器将 HTML 渲染为 PDF

IronPdfEngine 的其他说明

IronPdf .NET 不需要 IronPdfEngine 运行。 IronPdfEngine 只是使用 IronPdf 的一种可选方式。 默认情况下,IronPdf for .NET 将不使用 IronPdfEngine。

请注意每个版本的 IronPdf for .NET 都需要特定版本的 IronPdfEngine。不支持跨版本。
对于 IronPdf for .NET,所需的 IronPdfEngine 将始终匹配。 例如,IronPdf 2024.2.2 将使用 IronPdfEngine 2024.2.2)}]

IronPdf .NET 与远程 IronPdfEngine

IronPdf.slim NuGet 包是使用 IronPdf for .NET 与远程 IronPdfEngine 所需的唯一包。

请注意如果您正在使用 IronPdfIronPdf.Linux,可以使用 IronPdf.slim 代替以减少应用程序大小。

假设 IronPdfEngine 远程运行在 123.456.7.8:33350

使用 NuGet 安装 IronPdf:

Install-Package IronPdf.Slim

安装 IronPdf.slim 后,您只需告诉 IronPdf IronPdfEngine 的位置(请确保该地址可访问,不被防火墙阻止)。 使用 IronPdfConnectionConfiguration 类配置连接设置。 在应用程序初始化阶段添加以下代码(或在调用任何 IronPdf 方法之前)。

// Connect to the remote IronPdfEngine
Installation.ConnectToIronPdfHost(
    IronPdf.GrpcLayer.IronPdfConnectionConfiguration.RemoteServer("123.456.7.8:33350")
);
// Connect to the remote IronPdfEngine
Installation.ConnectToIronPdfHost(
    IronPdf.GrpcLayer.IronPdfConnectionConfiguration.RemoteServer("123.456.7.8:33350")
);
' Connect to the remote IronPdfEngine
Installation.ConnectToIronPdfHost(IronPdf.GrpcLayer.IronPdfConnectionConfiguration.RemoteServer("123.456.7.8:33350"))
$vbLabelText   $csharpLabel

就这么简单! 之后,您的应用程序将连接到远程 IronPdfEngine!

<hr

IronPdfEngine 的限制

  • 目前,IronPdfEngine 尚不支持水平扩展(使用多个实例的负载平衡),因为我们将处理 PDF 文件的二进制文件存储在服务器内存中,并使用 PdfDocumentId 在服务器和客户端之间通信。 这也最大限度地减少了带宽使用并提高了处理速度。
  • 要远程运行 IronPdfEngine Docker,您需要确保 IronPdfEngine 端口是可访问的。
  • 使用基于官方 ubuntu:22.04 镜像在 Linux x64(Debian)上运行的 IronPdfEngine Docker 可能生成的 PDF 输出与在本地运行 IronPdf 时略有不同,这是由于操作系统行为不同。
  • 由于 IronPdfEngine Docker 是基于 Linux 的,它需要 Linux 容器守护程序(如果您使用的是 Windows,请选择切换到 Linux 容器)。
  • IronPdfEngine 二进制文件不是跨平台的,因此我们专门为每个平台构建它们。
  • 不支持跨版本。

常见问题解答

我如何设置IronPdfEngine进行远程PDF生成?

要设置IronPdfEngine进行远程PDF生成,请从NuGet安装IronPdf.Slim包,并使用IronPdfConnectionConfiguration类配置连接设置。此设置允许您将应用程序远程连接到IronPdfEngine实例。

使用IronPdfEngine与我的应用程序的主要好处是什么?

在应用程序中使用IronPdfEngine可以远程执行PDF任务,帮助避免平台特定的兼容性问题,特别是在旧系统和移动平台上。此外,它在执行期间不需要.NET运行时。

为什么我可能选择使用IronPdfEngine而不是本地PDF库?

您可能选择使用IronPdfEngine来远程运行性能密集型的PDF功能,减少与不同操作系统的兼容性问题,并通过利用与Chrome相同的渲染器提高HTML到PDF转换的性能。

IronPdfEngine支持水平扩展吗?

不,IronPdfEngine目前不支持水平扩展,这意味着由于服务器内存中PDF文件二进制文件的处理方式,它无法负载均衡到多个实例。

IronPdfEngine可以在不同操作系统上运行吗?

IronPdfEngine设计用于使用Docker容器在Linux系统上运行。然而,二进制文件是平台特定的,因此您需要确保使用适合您操作系统的版本。

如果使用IronPdfEngine时我的PDF输出不同,我该怎么办?

由于不同操作系统的行为,PDF输出可能会略有不同。为了减少差异,请确保您使用正确的Docker镜像,并检查可能影响渲染的任何操作系统特定设置。

我如何确保我的应用程序使用正确版本的IronPdfEngine?

为了确保兼容性,每个版本的IronPDF都需要匹配版本的IronPdfEngine。请确保同时更新两个组件,以避免跨版本问题。

在Windows上使用IronPdfEngine有哪些限制?

在Windows上使用IronPdfEngine时,您需要Linux Containers for Docker,并必须确保服务器端口可访问。二进制文件是平台特定的,需要切换到Linux Containers。

如何配置IronPDF以连接到远程IronPdfEngine服务器?

要为远程服务器配置IronPDF,请使用Installation.ConnectToIronPdfHost方法中的IronPdf.GrpcLayer.IronPdfConnectionConfiguration.RemoteServer,指定服务器的IP和端口详细信息。

使用IronPdfEngine时应该使用哪个包以最小化应用程序大小?

您应使用NuGet中的IronPdf.Slim包,因为它仅包含运行IronPDF与IronPdfEngine所需的组件,从而减少应用程序大小。

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

准备开始了吗?
Nuget 下载 16,154,058 | 版本: 2025.11 刚刚发布