PDF檔案的URL
將網頁 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.");
}
}$vbLabelText $csharpLabel




