URL 到 PDF 從網頁 URL 渲染成 PDF 就像提供 URL 給 fromUrl 方法一樣簡單。 這將回傳一個 PDF 物件,可以匯出或進行進一步的 PDF 文件強化。 有關使用 IronPDF 將網頁轉換為 PDF 的其他資訊,請參閱 IronPDF HTML 至 PDF 轉換指南。 // Import necessary namespace using IronPdf; class Program { static void Main() { // Define the URL of the web page you want to convert to a PDF var url = "https://example.com"; // Create an instance of IronPdf.HtmlToPdf var renderer = new HtmlToPdf(); // Render the URL to a PDF document // The fromUrl method takes the web page URL and returns a PdfDocument object PdfDocument pdf = renderer.RenderUrlAsPdf(url); // Export the PDF document to a file // Specify the file path where the PDF will be saved pdf.SaveAs("WebPageToPdf.pdf"); // Output success message System.Console.WriteLine("Web page has been successfully converted to PDF."); } } // Import necessary namespace using IronPdf; class Program { static void Main() { // Define the URL of the web page you want to convert to a PDF var url = "https://example.com"; // Create an instance of IronPdf.HtmlToPdf var renderer = new HtmlToPdf(); // Render the URL to a PDF document // The fromUrl method takes the web page URL and returns a PdfDocument object PdfDocument pdf = renderer.RenderUrlAsPdf(url); // Export the PDF document to a file // Specify the file path where the PDF will be saved pdf.SaveAs("WebPageToPdf.pdf"); // Output success message System.Console.WriteLine("Web page has been successfully converted to PDF."); } } ' Import necessary namespace Imports IronPdf Friend Class Program Shared Sub Main() ' Define the URL of the web page you want to convert to a PDF Dim url = "https://example.com" ' Create an instance of IronPdf.HtmlToPdf Dim renderer = New HtmlToPdf() ' Render the URL to a PDF document ' The fromUrl method takes the web page URL and returns a PdfDocument object Dim pdf As PdfDocument = renderer.RenderUrlAsPdf(url) ' Export the PDF document to a file ' Specify the file path where the PDF will be saved pdf.SaveAs("WebPageToPdf.pdf") ' Output success message System.Console.WriteLine("Web page has been successfully converted to PDF.") End Sub End Class $vbLabelText $csharpLabel 在我們的 HTML 至 PDF 轉換指南中瞭解更多資訊。 相關文檔連結 在 Github 上查看 相關教程 相關操作指南 類文檔 獲取語言包 下載 IronPDF DLL 報告此頁面上的問題 準備好開始了嗎? 版本: 2025.11 剛剛發布 免費的 npm 安裝 查看許可證