HTML to PDF using C#

ironpdf makes it easy to generate pdfs from c# / .net applcations and web sites

C# PDF

Generate Pdfs in C# using HTML

IronPDF.HtmlToPdf is a PDF generator class for Microsoft .Net web applications, writtn in C#

The class can make print quality PDFs from an HTML input string or directly from a webpage or url

Simply put HtmlToPdf allows any .Net application or website to generate PDF files. HtmlToPdf uses HTML as the design language, avoiding teh need to lear an new, obscure API.   Install Now »

Start generating PDFs in .Net in 60 seconds…

Install C# PDF into Visual Studio

Install HTMLToPdf to your C# / .Net Project

The easiest way to install HTMLToPdf and the IronPDf library is by using NuGet Package Manager for Visual-Studio:

  1. The package name is "IronPdf"
  2. If NuGet is unfamiliar to you… read this tutorial
  3. If you would prefer to download IronPDF as a dll and install manually, be our guest.
C# PDF Example Code Demo

Get Coding

IronPDF has a very simple API based on HTML as a design language:

using IronPdf;

HtmlToPdf HtmlToPdf = new IronPdf.HtmlToPdf();
PdfResource PDF = HtmlToPdf.RenderUrlAsPdf(@"http://myurl.com");
PDF.SaveAs(@"Path\File.Pdf");

// or System.IO.MemoryStream PdfStream = PDF.GetStream;
// or byte[] PdfBinary = PDF.GetBinary;
using IronPdf;

HtmlToPdf HtmlToPdf = new IronPdf.HtmlToPdf();

HtmlToPdf.PrintOptions.Dpi = 300;
HtmlToPdf.PrintOptions.PDFPaperSize = PDFPrintOptions.PaperSize.A4;
HtmlToPdf.PrintOptions.EnableJavaScript = true;
HtmlToPdf.PrintOptions.AllowScreenCss = false;
HtmlToPdf.PrintOptions.Header = "{page} of {total-pages}";
HtmlToPdf.PrintOptions.GrayScale = false;
//.. many more options available
using IronPdf;

HtmlToPdf HtmlToPdf = new IronPdf.HtmlToPdf();
PdfResource PDF = HtmlToPdf.RenderUrlAsPdf(@"http://www.example.com");
PDF.SaveAs(@"Path\File.Pdf");

// or System.IO.MemoryStream PdfStream = PDF.GetStream;
// or byte[] PdfBinary = PDF.GetBinary;
using IronPdf;

private void Form1_Load(object sender, EventArgs e)
{
  PDFPrintOptions Options = new PDFPrintOptions()
  {
    Dpi = 300,
    EnableJavaScript = false,
     //.. many more options available  
  };
  AspxToPdf.RenderThisPageAsPDF(AspxToPdf.FileBehaviour.Attachment);
}
using IronPdf;

  private void Form1_Load(object sender, EventArgs e)
  {
  //...
  AspxToPdf.RenderThisPageAsPDF();      
  //Changes the ASPX output into a pdf instead of html   
  }
Imports IronPdf

Dim HtmlToPdf As HtmlToPdf = New IronPdf.HtmlToPdf()
Dim PDF As PdfResource = HtmlToPdf.RenderUrlAsPdf("http://myurl.com")
PDF.SaveAs("Path\File.Pdf")

' or Dim PdfStream = PDF.GetStream;
' or Dim PdfBinary = PDF.GetBinary;
Imports IronPdf

Dim HtmlToPdf = New IronPdf.HtmlToPdf()

HtmlToPdf.PrintOptions.Dpi = 300
HtmlToPdf.PrintOptions.PDFPaperSize = PDFPrintOptions.PaperSize.A4
HtmlToPdf.PrintOptions.EnableJavaScript = True
HtmlToPdf.PrintOptions.AllowScreenCss = False
HtmlToPdf.PrintOptions.Header = "{page} of {total-pages}"
HtmlToPdf.PrintOptions.GrayScale = False
'.. many more options available
Imports IronPdf

Dim HtmlToPdf = New IronPdf.HtmlToPdf()
Dim PDF = HtmlToPdf.RenderUrlAsPdf("http://www.example.com")
PDF.SaveAs("Path\File.Pdf")

' or Dim PdfStream = PDF.GetStream;
' or Dim PdfBinary = PDF.GetBinary;
Imports IronPdf

Private Sub Form1_Load(sender As Object, e As EventArgs)
  
  Dim Options As New PDFPrintOptions() With { _
  Key .Dpi = 300, _
  Key .EnableJavaScript = False _
  }
  '.. many more options available  
  AspxToPdf.RenderThisPageAsPDF(AspxToPdf.FileBehaviour.Attachment)
End Sub
Imports IronPdf

  Private Sub Form1_Load(sender As Object, e As EventArgs)
  '...
  AspxToPdf.RenderThisPageAsPDF()    
  'Changes the ASPX output into a pdf instead of html   
  End Sub

This is the droid you have been looking for…

C# PDF Gererator Documentation

Well Documented

Clear online manuals in plain English.

C# & VB Docs
C# PDF Library Licensing

Flexibly Licensed

Free Development. Commercial from $299.

Explore Licenses
C# PDF Open-Source Examples

Human Support

Talk directly with our development team

Ask a Question
visual studio Install C# PDF Generator by IronPdf

1 Minute Setup

Use Nuget Package Manager to install in under 60 seconds.