How to Render URL to PDF
Rendering existing URLs as PDFs with C# is very efficient and intuitive. IronPDF makes it very straightforward to render HTML from existing URLs as PDF documents. There is a very high level of support for JavaScript, Images, Forms, and CSS.
Get started with IronPDF
Start using IronPDF in your project today with a free trial.
How to Render URL to PDF
- Download IronPDF C# Library from NuGet
- Instantiate the ChromePdfRenderer class
- Learn How to Render PDFs from URLs
- Modify the RenderingOptions to add header and footer
- Check the PDF Output Document
Convert URL to PDF Example
Here we have an example of IronPDF rendering a Wikipedia webpage into PDF by using the RenderUrlAsPdf()
method. The parameter is an absolute (fully formed) Uri. This 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")
Result
This is the file that the code produced: