Code Samples for C#/VB .NET Core

C# VB PDF .NET : Using HTML To Create a PDFUsing HTML To Create a PDF
using IronPdf;

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

// Create a PDF from a HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");

// Export to a file or Stream
pdf.SaveAs("output.pdf");

// Advanced Example with HTML Assets
// Load external html assets: Images, CSS and JavaScript.
// An optional BaseUrlOrPath 'C:\site\assets\' is set as the file location to load assets from
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
NuGet Downloads Badge
PM > Install-Package IronPdf

With IronPDF, you can create new PDF documents from HTML strings within a .NET project, and IronPDF can be used from C#, F# and VB.NET. The ChromePdfRenderer class renders the HTML with a built-in Chromium engine, and the guide to pixel-perfect HTML to PDF explains how to match the output to the browser. The HTML to PDF tutorial covers the wider set of conversion features.

The first step to converting an HTML string to a PDF in C# is to install the IronPDF library in the project. The using IronPdf directive at the top of the example gives access to the classes needed for HTML to PDF conversion.

The example creates an instance of ChromePdfRenderer, which handles the conversion of HTML to PDF. The RenderHtmlAsPdf method converts a simple HTML string ("<h1>Hello World</h1>") into a PDF document, and the SaveAs method writes that document to disk.

In the advanced example, IronPDF renders HTML that refers to external assets such as images, CSS and JavaScript files. The optional BaseUrlOrPath argument of RenderHtmlAsPdf sets the folder or URL against which relative paths resolve, so icons/iron.png loads from the icons folder under that base path. The resulting PDF, which includes the external assets, is saved with the same method. For paper size, margins, headers, footers and other output settings, see the guide to rendering options.

Warning: Set Installation.EnableWebSecurity = true when rendering untrusted HTML from users. Web security disables operations that require local disk access or cross-origin requests, so local assets, such as the image in the advanced example, do not load.
Learn to Convert HTML Strings to PDF in C# with IronPDF

Support For .NET Core Coders

Regardless of whether its technical or sales inquiries, the Iron Team are close by to help with the majority of your questions. Connect with Iron to benefit as much as possible from our library in your project.
C# .NET HTML-to-PDF

C# & VB HTML-to-PDF Library for .NET Core

IronPDF utilizes a Chromium renderer for .NET Chromium to convert HTML files to PDF documents. There's no need for APIs to position or layout PDFs: IronPDF uses standard HTML, ASPX, JS, CSS and Images.
C# .NET PDF OCR Library

Read PDF Text

IronPDF enables you to extract all embedded text content from PDFs to pass into your C# & .NET Core APPs. Import content from PDF archives into your business process systems.
How To Edit PDF Documents in C#

Edit PDFs in .NET Core

From Appending, converging, parting, and altering PDFs, utilize your own coding skills to precisely to get the correct PDF every time. IronPDF puts the development capabilities specifically into your hands, inside your C#/VB .NET Core Project.
Convert HTML5, JS, CSS and Image files to PDF documents using .NET Code.

Supports Your Document Types

Point IronPDF .NET Core Library at your HTML file, string or URL to simply convert to PDF. This uses your current documents and website pages to render your information to a PDF file.
Visual Studio Library for PDF Creation and Content Editing.

Get Going Fast with Microsoft Visual Studio

IronPDF puts PDF creation and editing control in your very own hands, rapidly with complete intellisense support and a Visual Studio installer. Use NuGet for Visual Studio or download the DLL. You'll be set up in a matter of moments. Only one DLL.

Supports:

  • .NET Core 2 and above
  • .NET Framework 4.0 and above support C#, VB, F#
  • Microsoft Visual Studio. .NET Development IDE Icon
  • NuGet Installer Support for Visual Studio
  • JetBrains ReSharper C# language assistant compatible
  • Microsoft Azure C# .NET  hosting platform compatible

Licensing & Pricing

Free community development licenses. Commercial licenses from $999.

View Full License Options

C# PDF Tutorials From Our Community

Tutorial + Code Examples ASPX to PDF | ASP.NET Tutorial
C#PDFASP.NETASPX
Jacob Müller Software Product Designer @ Team Iron

ASPX to PDF | ASP.NET Tutorial

Learn how to turn any ASP.NET ASPX page into a PDF document into a PDF instead of HTML using a single line of code in C# or VB.NET…

View Jacob's ASPX-To-PDF Example
Tutorial + Code Examples C# HTML to PDF | C Sharp & VB.NET Tutorial
C#PDFHTML
Jean Ashberg .NET Software Engineer

C# HTML to PDF | C Sharp & VB.NET Tutorial

For many this is the most efficient way to generate PDF files from .NET, because there is no additional API to learn, or complex design system to navigate…

See Jean's HTML-To-PDF Examples
Tutorial + Code Examples VB.NET PDF Creation and Editing | VB.NET &amp; ASP.NET PDF
VBPDFASP.NET
Veronica Sillar .NET Software Engineer

VB.NET PDF Creation and Editing | VB.NET & ASP.NET PDF

Learn how to create and edit PDF documents in VB.NET applications and websites. A free tutorial with code examples.…

View Veronica's VB.NET PDF Tutorial

Thousands of developers use IronPDF for...

Accounting and Finance Systems

  • # Receipts
  • # Reporting
  • # Invoice Printing
Add PDF Support to ASP.NET Accounting and Finance Systems

Business Digitization

  • # Documentation
  • # Ordering & Labelling
  • # Paper Replacement
C# Business Digitization Use Cases

Enterprise Content Management

  • # Content Production
  • # Document Management
  • # Content Distribution
.NET CMS PDF Support

Data and Reporting Applications

  • # Performance Tracking
  • # Trend Mapping
  • # Reports
C# PDF Reports
Join Them Today
Iron Software Enterprise .NET Component Developers
C# Library Developers

Thousands of corporations, governments, SMEs and developers alike trust Iron software products.

Iron's team have over 10 years experience in the .NET software component market.

South Australia Government
Smith & Nephew
Tennessee State Government
Turkish Airlines
3M
Rakuten
Europcar
GSK

Ready to Get Started?

Nuget Downloads 22,024,882Version:2026.11just released