HTML to PDF

C# + VB.Net: HTML to PDF HTML to PDF
using IronPdf;

IronPdf.HtmlToPdf Renderer = new IronPdf.HtmlToPdf();

// Render an HTML document or snippet as a string
Renderer.RenderHtmlAsPdf("<h1>Hello World</h1>").SaveAs("html-string.pdf");


// Advanced: 
// Set a "base url" or file path so that images, javascript and CSS can be loaded  
var PDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>",@"C:\site\assets\");
PDF.SaveAs("html-with-assets.pdf");
Imports IronPdf



Dim Renderer As New IronPdf.HtmlToPdf()

' Render an HTML document or snippet as a string
Renderer.RenderHtmlAsPdf("<h1>Hello World</h1>").SaveAs("html-string.pdf")


' Advanced: 
' Set a "base url" or file path so that images, javascript and CSS can be loaded  
Dim PDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>","C:\site\assets\")
PDF.SaveAs("html-with-assets.pdf")

IronPDF allows developers to create PDF documents easily in C#, F#, and VB.Net for .NET Core and .NET Framework. In this example we show that a PDF document can be rendered using HTML. You can choose simple HTML like the above, or incorporate CSS, images and Javascript. IronPDF rendering closely follows Google Chrome.