URL en PDF

La conversion d'une URL web en PDF est aussi simple que de fournir l'URL à la méthode fromUrl. Cela renverra un objet PDF qui peut être exporté ou faire l'objet d'autres améliorations du document PDF. Pour des informations supplémentaires sur la conversion de pages web en PDF à l'aide d'IronPDF, explorez le Guide de Conversion HTML en PDF d'IronPDF.

// 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

En savoir plus dans notre Guide de Conversion HTML en PDF.

Prêt à commencer?
Version : 2025.11 vient de sortir