IronPDF 故障排除 IronPdf.Linux 在 Linux 上執行IronPDF :設定指南 Curtis Chau 更新:2025年6月1日 下載 IronPDF NuGet 下載 DLL 下載 Windows Installer 開始免費試用 LLM副本 LLM副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 This article was translated from English: Does it need improvement? Translated View the article in English IronPDF Linux 版約 280MB(包括IronPDF程式碼和整個 Chrome 瀏覽器)。 Docker 映像大小約為 500MB。 Chrome 也需要一些基本軟體包,這些軟體包會根據您的 Linux 發行版而有所不同。 大多數 Linux 發行版都已安裝了這些軟體包,因為 Linux 上的各種應用程式和函式庫都會使用它們。 但是,如果您使用的是精簡版發行版,則需要安裝必要的 Linux 軟體套件才能在 Linux 上執行 Chrome。 注意:為了方便調試,您可以設定以下參數: // 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 您也可以選擇僅包含IronPDF,並在執行時下載必要的檔案。 從你的專案中移除IronPDF(以及任何其他IronPDF) NuGet包,並加入IronPDF。 在初始化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 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; $vbLabelText $csharpLabel 確保應用程式目錄可寫入/可執行: RUN chmod +rwx /app/ 結合第 1 點和第 2 點,一個非常精簡的 Docker 映像應該可以將大小從約 500MB 減少到約 200MB。 如果可能的話,不選擇精簡部署方式將獲得最佳效能。 某些容器化和雲端環境不持久,因此可能需要偶爾重新下載依賴項或再次執行apt-get命令,這可能需要幾分鐘! 但是,我們也了解到,有些開發者在部署時可能會受到嚴格的規模要求。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? Nuget 下載 17,803,474 | 版本: 2026.3 剛剛發布 開始免費試用 免費 NuGet 下載 總下載量:17,803,474 查看許可證 還在滾動嗎? 想快速取得證據? PM > Install-Package IronPdf 運行範例看著你的HTML程式碼變成PDF檔。 免費 NuGet 下載 總下載量:17,803,474 查看許可證