How to Render URL to PDF

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.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPDF with NuGet

    PM > Install-Package IronPdf

  2. Copy the code

    IronPdf.ChromePdfRender
           .StaticRenderUrlAsPdf("https://example.com/")
           .SaveAs("example-com.pdf");
  3. Deploy to test on your live environment

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

Get started with IronPDF

Start using IronPDF in your project today with a free trial.

First Step:
green 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:

Frequently Asked Questions

How can I render a URL as a PDF in C#?

You can render a URL as a PDF in C# by using the IronPdf.ChromePdfRenderer class. The method StaticRenderUrlAsPdf allows you to convert a URL to a PDF with just one line of code.

What steps are needed to get started with URL to PDF conversion in C#?

To get started with URL to PDF conversion in C#, first download the IronPDF library from NuGet. Then, create an instance of the ChromePdfRenderer class, and use the RenderUrlAsPdf method to convert your URL to a PDF. You can also customize the PDF by modifying the RenderingOptions.

Does IronPDF support the rendering of JavaScript and CSS in web pages?

Yes, IronPDF provides robust support for rendering JavaScript, images, forms, and CSS when converting HTML content from URLs into PDFs.

Can I add headers and footers to my PDF when converting from a URL?

Yes, you can add headers and footers to your PDF by modifying the RenderingOptions in IronPDF before performing the conversion.

Is there example code for converting a webpage to PDF?

Yes, the documentation includes an example of using the RenderUrlAsPdf method to convert a Wikipedia webpage into a PDF. This requires an absolute URI of the webpage.

What type of URL format is required for converting to PDF?

The URL must be a fully formed absolute URI that points to the HTML document you want to render as a PDF.

Can IronPDF handle dynamic content when rendering a URL to PDF?

Yes, IronPDF can handle dynamic content, including JavaScript-based elements, during the conversion of a URL to PDF.

Regan Pun
Software Engineer
Regan graduated from the University of Reading, with a BA in Electronic Engineering. Before joining Iron Software, his previous job roles had him laser-focused on single tasks; and what he most enjoys at Iron Software is the spectrum of work he gets to undertake, whether it’s adding value to ...Read More