Cómo convertir y descargar un PDF desde una URL en C#

How to Render URL to PDF

This article was translated from English: Does it need improvement?
Translated
View the article in English

Rendering existing URLs as PDFs with C# is very efficient and intuitive. IronPDF makes it straightforward to render HTML from existing URLs as PDF documents. There is a very high level of support for JavaScript, Images, Forms, and CSS.

Quickstart: Convert a Web Page to PDF using IronPDF

Transform any webpage into a PDF in seconds using IronPDF. This quick and easy guide demonstrates how to employ the ChromePdfRenderer class to seamlessly convert URLs into high-quality PDFs with minimal code. Perfect for developers who need a fast, reliable way to integrate PDF rendering into their C# projects.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. Copy and run this code snippet.

    new IronPdf.ChromePdfRenderer().RenderUrlAsPdf("https://example.com").SaveAs("example.pdf");
  3. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer


Convert URL to PDF Example

Here we have an example of IronPDF rendering a Wikipedia webpage into PDF by using the RenderUrlAsPdf() method. This method requires an absolute (fully formed) URI that points to the HTML document to be rendered as a PDF.

:path=/static-assets/pdf/content-code-examples/how-to/url-to-pdf.cs
using IronPdf;

// Instantiate Renderer
var renderer = new ChromePdfRenderer();

// Create a PDF from a URL or local file path
var pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page");

// Export to a file or Stream
pdf.SaveAs("url.pdf");
Imports IronPdf

' Instantiate Renderer
Private renderer = New ChromePdfRenderer()

' Create a PDF from a URL or local file path
Private pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page")

' Export to a file or Stream
pdf.SaveAs("url.pdf")
$vbLabelText   $csharpLabel

Result

This is the file that the code produced:

Preguntas Frecuentes

¿Cómo puedo renderizar una URL como PDF en C#?

Puedes renderizar una URL como PDF en C# utilizando la clase IronPdf.ChromePdfRenderer. El método StaticRenderUrlAsPdf te permite convertir una URL a PDF con solo una línea de código.

¿Qué pasos son necesarios para comenzar con la conversión de URL a PDF en C#?

Para comenzar con la conversión de URL a PDF en C#, primero descarga la biblioteca IronPDF desde NuGet. Luego, crea una instancia de la clase ChromePdfRenderer, y usa el método RenderUrlAsPdf para convertir tu URL a PDF. También puedes personalizar el PDF modificando los RenderingOptions.

¿IronPDF admite la renderización de JavaScript y CSS en páginas web?

Sí, IronPDF proporciona un soporte robusto para renderizar JavaScript, imágenes, formularios y CSS al convertir contenido HTML de URLs a PDFs.

¿Puedo agregar encabezados y pies de página a mi PDF al convertir desde una URL?

Sí, puedes agregar encabezados y pies de página a tu PDF modificando los RenderingOptions en IronPDF antes de realizar la conversión.

¿Hay un código de ejemplo para convertir una página web a PDF?

Sí, la documentación incluye un ejemplo de uso del método RenderUrlAsPdf para convertir una página web de Wikipedia en PDF. Esto requiere una URI absoluta de la página web.

¿Qué tipo de formato de URL se requiere para convertir a PDF?

La URL debe ser una URI absoluta completamente formada que apunte al documento HTML que deseas renderizar como PDF.

¿Puede IronPDF manejar contenido dinámico al renderizar una URL en PDF?

Sí, IronPDF puede manejar contenido dinámico, incluidos elementos basados en JavaScript, durante la conversión de una URL a PDF.

¿IronPDF es totalmente compatible con .NET 10 para conversiones de URL a PDF?

Sí, IronPDF ofrece compatibilidad total con .NET 10, sin necesidad de configuración especial. Puede renderizar URLs a PDF igual que en versiones anteriores de .NET, usando ChromePdfRenderer.RenderUrlAsPdf y las mismas opciones de renderizado. IronPDF es compatible con .NET 10, 9, 8 y más.

Regan Pun
Ingeniero de Software
Regan se graduó de la Universidad de Reading, con una licenciatura en Ingeniería Electrónica. Antes de unirse a Iron Software, sus roles anteriores lo tenían enfocado en tareas individuales; y lo que más disfruta en Iron Software es la variedad de trabajos que puede realizar, ya ...
Leer más
¿Listo para empezar?
Nuget Descargas 16,154,058 | Versión: 2025.11 recién lanzado