IronPDF 故障排除 渲染 PDF 时超时 Fixing PDF Rendering Timeout Issues Curtis Chau 更新日期:6月 9, 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 無法從 HTML 渲染 PDF 無法從 URL 渲染 PDF 從 HTML 生成 PDF 時出錯 從 URL 生成 PDF 時出錯 未指定的本機異常 這些常見的錯誤信息表明 Chrome 渲染引擎遇到故障。 應用以下代碼片段將生成一個 “Default.log” 日誌文件,這有助於確定故障的原因。 // Enable logging for all events and set the file path for the log file. IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All; IronPdf.Logging.Logger.LogFilePath = "Default.log"; // Enable logging for all events and set the file path for the log file. IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All; IronPdf.Logging.Logger.LogFilePath = "Default.log"; ' Enable logging for all events and set the file path for the log file. IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All IronPdf.Logging.Logger.LogFilePath = "Default.log" $vbLabelText $csharpLabel 渲染超時 超時是 IronPDF 實施的一項功能,旨在防止應用程序因 PDF 渲染時間過長而死鎖和無響應。 這可以幫助用戶管理資源,確保 CPU、內存和網絡帶寬等資源不會因需要很長時間完成的進程而被占用。 如果 PDF 渲染過程未能及時完成,則會拋出如下面所述的超時錯誤。 從 HTML 渲染 PDF 持續 60s 超時 從 URL 渲染 PDF 持續 60s 超時 從 HTML 生成 PDF 超時 從 URL 生成 PDF 超時 從 HTML 渲染 PDF 超時 從 URL 渲染 PDF 超時 IronPDF 中渲染時間過長可能會導致超時錯誤的原因很多,例如渲染大而繁重的 PDF、檢索渲染 PDF 所需的遠程資源/資產,或渲染過程中的問題。 然而,覆蓋超時時間通常可以解決問題。 要覆蓋默認設置,用戶可以訪問 Timeout 屬性 在 ChromePdfRenderOptions 類中將其設置為更高的值。 // Set the timeout for rendering to 120 seconds. RenderingOptions.Timeout = 120; // seconds // Set the timeout for rendering to 120 seconds. RenderingOptions.Timeout = 120; // seconds ' Set the timeout for rendering to 120 seconds. RenderingOptions.Timeout = 120 ' seconds $vbLabelText $csharpLabel 請注意從 2021.12.4995 版開始,IronPDF 的默認渲染超時時間為 60 秒。 渲染延遲 在某些情況下,IronPDF 可能會渲染: 空白 PDF 含不完整內容的 PDF 漏失圖片資產的 PDF 此問題可能是因為在完成內容或資產的檢索調用之前渲染了 PDF 文件。 通常通過在 PDF 渲染器上應用渲染延遲可以幫助解決此問題。 這將指示渲染器將 PDF 渲染推遲一段時間,以便在 PDF 渲染之前及時加載內容或資產。 為此,只需訪問 RenderDelay() 方法在 WaitFor 包裝對象中,將所需的持續時間作為方法參數設置,並將其應用於渲染器作為 ChromePdfRenderOptions 屬性之一。 // Set a render delay of 5000 milliseconds (5 seconds) to ensure content and assets are loaded before rendering. RenderingOptions.WaitFor.RenderDelay(5000); // milliseconds // Set a render delay of 5000 milliseconds (5 seconds) to ensure content and assets are loaded before rendering. RenderingOptions.WaitFor.RenderDelay(5000); // milliseconds ' Set a render delay of 5000 milliseconds (5 seconds) to ensure content and assets are loaded before rendering. RenderingOptions.WaitFor.RenderDelay(5000) ' milliseconds $vbLabelText $csharpLabel 請注意默認的 RenderDelay 持續時間為 20 毫秒 除了 RenderDelay() 方法,WaitFor 包裝對象中還有其他方法可以利用。 如需進一步了解日誌和報告錯誤給我們的工程師以供審核,請參閱 如何為 IronPDF 提出工程支持請求。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? Nuget 下載 16,154,058 | 版本: 2025.11 剛剛發布 免費 NuGet 下載 總下載量:16,154,058 查看許可證