IronPDF 故障排除 IronPdf.Linux Running IronPDF on Linux: Setup Guide Curtis Chau 更新日期:6月 1, 2025 Download IronPDF NuGet 下載 DLL 下載 Windows 安裝程式 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English IronPdf for Linux 大約 280MB(包括 IronPdf 代碼和整個 Chrome 瀏覽器)。 Docker 映像大約 500MB。 Chrome 也需要一些基本的包,這些包根據您的 Linux 發行版而有所不同。 大多數 Linux 發行版已經安裝了這些包,因為它們被 Linux 上的各種應用程序和庫使用。 然而,如果您使用的是一個基本發行版,您將需要安裝讓 Chrome 能夠在 Linux 上運行的 Linux 包。 注意:為了更輕鬆地進行調試,您可以設置以下參數: // Enable detailed debugging for IronPdf IronPdf.Logging.Logger.EnableDebugging = true; // Specify the log file path IronPdf.Logging.Logger.LogFilePath = "Default.log"; // Set the logging mode to capture all log data IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All; // Enable detailed debugging for IronPdf IronPdf.Logging.Logger.EnableDebugging = true; // Specify the log file path IronPdf.Logging.Logger.LogFilePath = "Default.log"; // Set the logging mode to capture all log data IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All; ' Enable detailed debugging for IronPdf IronPdf.Logging.Logger.EnableDebugging = True ' Specify the log file path IronPdf.Logging.Logger.LogFilePath = "Default.log" ' Set the logging mode to capture all log data IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All $vbLabelText $csharpLabel 如何製作更小的 Docker 映像 1. 在運行時安裝包 一種減少大小的方法是在運行時執行 apt-get 命令,而不是在構建 docker 映像時: 從您的 Dockerfile 中移除 apt-get 命令。 在初始化 IronPdf 或呈現文件之前,設置 Installation.LinuxAndDockerDependenciesAutoConfig = true;。 確保您的應用程序具備運行 apt-get 命令的足夠權限。 注意:您的第一次初始化將會比較慢,因為在呈現第一個文件之前,apt-get 命令必須完成,並且每次重新部署映像時該過程都會重複。 注意:您應該會在控制台/日誌中看到指示包安裝成功的條目: Executing command 'apt install -y libnss3' in '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native' Reading package lists... Building dependency tree... Reading state information... The following additional packages will be installed: libnspr4 The following NEW packages will be installed: libnspr4 libnss3 0 upgraded, 2 newly installed, 0 to remove and 9 not upgraded. Executing command 'apt install -y libnss3' in '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native' Reading package lists... Building dependency tree... Reading state information... The following additional packages will be installed: libnspr4 The following NEW packages will be installed: libnspr4 libnss3 0 upgraded, 2 newly installed, 0 to remove and 9 not upgraded. SHELL 2. 使用 IronPdf.Slim 您也可以選擇_僅_包含 IronPdf.dll 並在運行時下載必要的文件。 將 IronPdf.Linux(以及任何其他 IronPdf)NuGet 包從您的項目中移除並添加 IronPdf.Slim。 在初始化 IronPdf 或呈現文件之前,設置 Installation.AutomaticallyDownloadNativeBinaries = true;。 確保您的 Dockerfile 授予應用程序整個工作目錄的讀寫權限(例如,將 RUN chmod +rwx /app/runtimes/linux-x64/native/IronCefSubprocess 更改為 RUN chmod +rwx /app/)。 注意:您的第一次初始化將會比較慢,因為 在呈現第一個文件之前,NuGet 包下載並解壓,並且每次重新部署映像時該過程都會重複。 注意:您應該會在控制台/日誌中看到指示下載和解壓成功的條目: Downloading NuGet package from 'https://www.nuget.org/api/v2/package/IronPdf.Native.Chrome.Linux/2023.1.11387' Extracting package contents '/app/bin/Debug/netcoreapp3.1/IronPdf.Native.Chrome.Linux.2023.1.11387.nupkg/runtimes/linux-x64/native' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native' Successfully deployed NuGet package 'IronPdf.Native.Chrome.Linux' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native' Successfully located 'IronInterop' at '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native' Downloading NuGet package from 'https://www.nuget.org/api/v2/package/IronPdf.Native.Chrome.Linux/2023.1.11387' Extracting package contents '/app/bin/Debug/netcoreapp3.1/IronPdf.Native.Chrome.Linux.2023.1.11387.nupkg/runtimes/linux-x64/native' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native' Successfully deployed NuGet package 'IronPdf.Native.Chrome.Linux' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native' Successfully located 'IronInterop' at '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native' SHELL 3. 結論 總結來說,要減少_初始容器大小: 使用 IronPdf.Slim NuGet 包。 配置 IronPdf: // Set installation options for Linux and Docker environments Installation.LinuxAndDockerDependenciesAutoConfig = true; Installation.AutomaticallyDownloadNativeBinaries = true; // Set installation options for Linux and Docker environments Installation.LinuxAndDockerDependenciesAutoConfig = true; Installation.AutomaticallyDownloadNativeBinaries = true; ' Set installation options for Linux and Docker environments Installation.LinuxAndDockerDependenciesAutoConfig = True Installation.AutomaticallyDownloadNativeBinaries = True $vbLabelText $csharpLabel 確保應用程序目錄可寫/可執行: RUN chmod +rwx /app/ 如果使用上述兩點來利用非常小的 Docker 映像,則可以將大小從~500MB 減少到~200MB。 如果可能,您會看到最佳性能,但請勿選擇瘦部署。 一些容器化和雲環境不持久,因此可能偶爾需要重新下載依賴項或再次運行 apt-get 命令,需要花費幾分鐘的時間! 然而,我們理解有些開發人員可能會受到嚴格的部署大小要求。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? Nuget 下載 16,154,058 | 版本: 2025.11 剛剛發布 免費 NuGet 下載 總下載量:16,154,058 查看許可證