C# Create PDF - Full Tutorial
Published: 2021-12-09 08:56:47

---
canonical_url: https://ironpdf.com/blog/using-ironpdf/csharp-create-pdf-tutorial/
---

If you need to download HTML content from a webpage to a PDF file, then you are in the right place! Here you will be introduced to a versatile converter to convert the exact content of [HTML to PDF](https://ironpdf.com/)

**Steps to Create PDF from C# Library**

1. Install <a href="https://ironpdf.com/" target="_blank">C# Library</a> to create PDF Document
2. Import HTML Page either offline or online
3. Use Library and method 'RenderHtmlAsPdf("<TAG>")'
4. Convert the <a href="https://ironpdf.com/tutorials/html-to-pdf/" target="_blank">HTML to a PDF</a>
5. View PDF Document Output

As HTML is a markup language, it can be difficult to convert the contents of HTML to a PDF without the HTML tags. We'll be working with IronPDF for this tutorial to do just that, <a href="https://ironpdf.com/docs/questions/generate-pdf-in-csharp/" target="_blank">create PDF in C#</a> from HTML, because of its ease of use and additional features like using JavaScript, CSS, and images.

In this article, we are going to cover in detail, <a href="https://ironpdf.com/" target="_blank">HTML to PDF</a> conversion in C# provided by IronPDF.

When I need to create, read, generate or manipulate pdf files, I always prefer IronPDF, as it has the best library, is easy to use, and provides great features.

{% youtube y4hbMBuxqo4 %}

---
## Create PDF in C#

As HTML is a markup language, it can be difficult to convert the contents of HTML to a PDF without the HTML tags. Use the IronPDF C# library to access the simple HTML to PDF method. The software is available free for development, either via direct download [DLL ZIP file](https://ironpdf.com/packages/IronPdf.Package.For.Create.PDF.CSharp.zip) or by using <a href="https://www.nuget.org/packages/IronPdf" target="_blank" rel="nofollow">NuGet command</a>.

I have written a separate article on this topic, in which I have explained each and every step. Please visit this <a href="https://www.c-sharpcorner.com/article/how-to-create-pdf-file-in-c-sharp-using-ironpdf/" target="_blank" rel="nofollow">link</a>.

Here is an example:

**C#:**
```cs
string htmlText = "<h1> This is Sample Pdf file</h1> <p> This is the demo for Csharp Created Pdf using IronPdf </p> <p> IronPdf is a library which provides build in functions for creating, reading <br> and manuplating pdf files with just few lines of code. </p>";
var HtmlLine = new HtmlToPdf();
        HtmlLine.RenderHtmlAsPdf(PdfText.Text).SaveAs(filename);
```
**VB:**
```vb
Dim htmlText As String = "<h1> This is Sample Pdf file</h1> <p> This is the demo for Csharp Created Pdf using IronPdf </p> <p> IronPdf is a library which provides build in functions for creating, reading <br> and manuplating pdf files with just few lines of code. </p>"
Dim HtmlLine = New HtmlToPdf()
		HtmlLine.RenderHtmlAsPdf(PdfText.Text).SaveAs(filename)
```

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zpu8by2ndbe3xoqkzskv.png)

## Render ASP.Net and MVC to PDF

It is possible to serve an existing HTML file or string, an existing PDF document, as well as a PDF in ASP.NET MVC. In order to serve existing PDF files, HTML files, or strings, as well as serving a PDF in ASP.NET MVC, we can use the C# PDF Library from IronPDF and then access it via [DLL ZIP file](https://ironpdf.com/packages/IronPdf.Package.For.MVC.View.PDF.zip) or throught the <a href="https://www.nuget.org/packages/IronPdf" target="_blank">NuGet page</a>.

To serve a PDF document in ASP.Net MVC requires generating a <a href="https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.fileresult" target="_blank" rel="nofollow" >FileResult</a> method. With Iron PDF you can use <a href="https://dotnet.microsoft.com/apps/aspnet/mvc" target="_blank" rel="nofollow">MVC</a> to return a PDF file.

**C#:**
```cs
 var Renderer = new IronPdf.ChromePdfRenderer();
 var PDF = Renderer.RenderHTMLFileAsPdf("Project/MyHtmlDocument.html");
// or to convert an HTML string
//var PDF = Renderer.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>");
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition","attachment;filename=\"FileName.pdf\"");
// edit this line to display ion browser and change the file name
Response.BinaryWrite( PDF.BinaryData );
Response.Flush();
Response.End();
```
**VB:**
```vb
Dim Renderer = New IronPdf.ChromePdfRenderer()
 Dim PDF = Renderer.RenderHTMLFileAsPdf("Project/MyHtmlDocument.html")
' or to convert an HTML string
'var PDF = Renderer.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>");
Response.Clear()
Response.ContentType = "application/pdf"
Response.AddHeader("Content-Disposition","attachment;filename=""FileName.pdf""")
' edit this line to display ion browser and change the file name
Response.BinaryWrite(PDF.BinaryData)
Response.Flush()
Response.End()
```

## 3. Render Razor Views to PDF

The following method makes it easy to render a Razor view to a string. IronPDF's <a href="https://ironpdf.com/tutorials/html-to-pdf/" target="_blank">HTML to PDF</a> functionality can be used to render that Razor view as a string. Don't forget to set the optional _BaseURI_ parameter of the **IronPdf.ChromePdfRenderer.RenderHtmlAsPdf** Method to load relative assets, CSS, JavScript, and images. Here is an example:

**C#:**
```cs
public string RenderRazorViewToString(string viewName, object model)
{
ViewData.Model = model;
    using (var sw = new StringWriter())
    {
        var viewResult = ViewEngines.Engines.FindPartialView(ControllerContext,
        viewName);
        var viewContext = new ViewContext(ControllerContext, viewResult.View,
        ViewData, TempData, sw);
        viewResult.View.Render(viewContext, sw);
        viewResult.ViewEngine.ReleaseView(ControllerContext, viewResult.View);
        return sw.GetStringBuilder().ToString();
    }
}
```
**VB:**
```vb
Public Function RenderRazorViewToString(ByVal viewName As String, ByVal model As Object) As String
ViewData.Model = model
	Using sw = New StringWriter()
		Dim viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName)
		Dim viewContext As New ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw)
		viewResult.View.Render(viewContext, sw)
		viewResult.ViewEngine.ReleaseView(ControllerContext, viewResult.View)
		Return sw.GetStringBuilder().ToString()
	End Using
End Function
```

Please read the <a href="https://ironpdf.com/docs/questions/asp-net-mvc-pdf-binary/" target="_blank">.NET MVC PDF</a> FAQ to learn how to render an MVC view as a binary PDF file.

## 4. Convert XML to PDF

C# XML to PDF directly can be a complex challenge. We've found that to convert XML to PDF in C# it is best to start with XSLT. XML and may be rendered to PDF via HTML(5) using XLST transformations.

These documents define how XML from a given schema may be converted to an accurate HTML representation and are a well-established standard.

The resultant HTML string or file may then be rendered as a PDF using the <a href="https://ironpdf.com/use-case/net-pdf-generator/" target="_blank">.NET PDF Generator</a>. 

Here is an example:

**C#:**
```cs
XslCompiledTransform transform = new XslCompiledTransform();
using(XmlReader reader = XmlReader.Create(new StringReader(XSLT))) {
    transform.Load(reader);
}
StringWriter results = new StringWriter();
using(XmlReader reader = XmlReader.Create(new StringReader(XML))) {
    transform.Transform(reader, null, results);
}
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
// options, headers and footers may be set there
// Render our XML as a PDF via XSLT
Renderer.RenderHtmlAsPdf(results.ToString()).SaveAs("Final.pdf");
```
**VB:**
```vb
Dim transform As New XslCompiledTransform()
Using reader As XmlReader = XmlReader.Create(New StringReader(XSLT))
	transform.Load(reader)
End Using
Dim results As New StringWriter()
Using reader As XmlReader = XmlReader.Create(New StringReader(XML))
	transform.Transform(reader, Nothing, results)
End Using
Dim Renderer As New IronPdf.ChromePdfRenderer()
' options, headers and footers may be set there
' Render our XML as a PDF via XSLT
Renderer.RenderHtmlAsPdf(results.ToString()).SaveAs("Final.pdf")
```

## 5. Generate PDF Reports

IronPDF can be used as a <a href="https://ironpdf.com/use-case/pdf-reader-csharp/" target="_blank">PDF reader C#</a> and help visualize and export SSRS reports to PDF in ASP.NET CSharp. IronPDF can be used to render snapshots of data as "reports" in the PDF File Format. It also works as a <a href="https://ironpdf.com/use-case/csharp-pdf-parser/" target="_blank">PDF C# parser</a>. The basic methodology is to generate the report as an HTML document - and then to render the HTML as a PDF using IronPDF.

To style an XML report, the XML may be parsed and then the HTML is generated with the data. These reports may be generated as HTML which may then be customized and converted to PDF format using IronPDF. The easiest way to serve HTML content in ASP.Net is to use the IronPdf.AspxToPdf class on the Form_Load event of an ASP.Net WebForms.

Here is an example:

**C#:**
```cs
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
// add a header to very page easily
Renderer.RenderingOptions.FirstPageNumber = 1;
Renderer.RenderingOptions.TextHeader.DrawDividerLine = true;
Renderer.RenderingOptions.TextHeader.CenterText = "{url}";
Renderer.RenderingOptions.TextHeader.FontFamily = "Helvetica,Arial";
Renderer.RenderingOptions.TextHeader.FontSize = 12;
// add a footer too
Renderer.RenderingOptions.TextFooter.DrawDividerLine = true;
Renderer.RenderingOptions.TextFooter.FontFamily = "Arial";
Renderer.RenderingOptions.TextFooter.FontSize = 10;
Renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}";
Renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}";
Renderer.RenderHtmlFileAsPdf("Report.html").SaveAs("Report.pdf");
```
**VB:**
```vb
Dim Renderer As New IronPdf.ChromePdfRenderer()
' add a header to very page easily
Renderer.RenderingOptions.FirstPageNumber = 1
Renderer.RenderingOptions.TextHeader.DrawDividerLine = True
Renderer.RenderingOptions.TextHeader.CenterText = "{url}"
Renderer.RenderingOptions.TextHeader.FontFamily = "Helvetica,Arial"
Renderer.RenderingOptions.TextHeader.FontSize = 12
' add a footer too
Renderer.RenderingOptions.TextFooter.DrawDividerLine = True
Renderer.RenderingOptions.TextFooter.FontFamily = "Arial"
Renderer.RenderingOptions.TextFooter.FontSize = 10
Renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}"
Renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}"
Renderer.RenderHtmlFileAsPdf("Report.html").SaveAs("Report.pdf")
```

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kkism28wyu0y8bb6cq1l.png)
I have used this [HTML template](https://gist.github.com/cemremengu/5365729) for generating a sample report. You can use your own HTML file.

## 6. Work with PDF Images and CSS

The answer, in this case of HTML String to PDF, is that we should set a BaseUri when working with assets. All assets such as CSS, JavaScript files, and images will be loaded relative to that base URL.

The BaseURL may be a web URL starting with “http” to load remote assets, or a local file path to access assets on your disk.

Another trick is to use the `IronPdf.Imaging.ImageUtilities.ImageToDataUri` method to convert any System.Drawing.Image or Bitmap object into an HTML string which can be embedded in HTML without saving to disk. Here is an example:

**C#:**
```cs
var PDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>",@"C:\site\assets\");
PDF.SaveAs("html-with-assets.pdf");
var Renderer = new IronPdf.ChromePdfRenderer();
var PDF = Renderer.RenderHTMLFileAsPdf("C:\\Assets\\TestInvoice1.html");
PDF.SaveAs("Invoice.pdf");
```
**VB:**
```vb
Dim PDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>","C:\site\assets\")
PDF.SaveAs("html-with-assets.pdf")
Dim Renderer = New IronPdf.ChromePdfRenderer()
Dim PDF = Renderer.RenderHTMLFileAsPdf("C:\Assets\TestInvoice1.html")
PDF.SaveAs("Invoice.pdf")
```

## 7. Convert ASPX Files to PDF

First, let's access the 'free for development' C# Library for converting ASPX files to PDF. You can <a href="https://ironpdf.com/packages/IronPdf.Package.For.Convert.ASPX.PDF.File.zip">download it directly</a> or access it via <a href="https://www.nuget.org/packages/IronPdf" target="_blank" rel="nofollow">NuGet</a>. Install as usual into your Visual Studio project. Now that you have IronPDF, you'll see that it has the functionality for HTML conversion as well as ASPX to PDF generation.

We can convert ASPX pages to either our own developed webpage or any website which is developed on ASP.NET. Here is an example:

**C#:**
```cs
using System;
using System.Web.UI;
using IronPdf;
namespace aspxtopdf
{
    public partial class SiteMaster : MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AspxToPdf.RenderThisPageAsPdf();
        }
    }
}
```
**VB:**
```vb
Imports System
Imports System.Web.UI
Imports IronPdf
Namespace aspxtopdf
	Partial Public Class SiteMaster
		Inherits MasterPage
		Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
			AspxToPdf.RenderThisPageAsPdf()
		End Sub
	End Class
End Namespace
```

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/49ijiqg8d6554zo3x824.png)

## 8. View HTML to PDF Example File

IronPDF converts HTML to PDF documents programmatically. It can be installed directly from IronPDF or via NuGet.

If you don't know about Installing IronPdf Nuget Packages, you can visit my previous <a href="https://www.c-sharpcorner.com/article/how-to-create-pdf-file-in-c-sharp-using-ironpdf/" target="_blank" rel="nofollow">article</a>.

The package name is <a href="https://www.nuget.org/packages/IronPdf/" target"_blank" rel="nofollow">IronPDF</a>. After IronPDF is installed and referenced in your project you can start using it right away by typing a couple of strings. Here is an example:

**C#:**
```cs
var uri = new Uri("https://www.c-sharpcorner.com/article/how-to-create-pdf-file-in-c-sharp-using-ironpdf/");
// turn page into pdf
var pdf = ChromePdfRenderer.StaticRenderUrlAsPdf(uri);
// save resulting pdf into file
pdf.SaveAs(Path.Combine(Directory.GetCurrentDirectory(), "UrlToPdf.Pdf"));
```
**VB:**
```vb
Dim uri As New Uri("https://www.c-sharpcorner.com/article/how-to-create-pdf-file-in-c-sharp-using-ironpdf/")
' turn page into pdf
Dim pdf = ChromePdfRenderer.StaticRenderUrlAsPdf(uri)
' save resulting pdf into file
pdf.SaveAs(Path.Combine(Directory.GetCurrentDirectory(), "UrlToPdf.Pdf"))
```

Pdf file is created inside the Debug folder of our App. Here is the output:


![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cnuuzvjpu0lxwdryz2yu.png)

## 9. Generate PDF File in C# .NET

With an extensive C# library, we can convert ASP.NET to PDF and HTML to PDF and have full control over reading, editing, and manipulating documents. Using IronPDF, we can convert an ASP.NET page to a PDF file in C# in just a single line of code.

To get access to the full software library of C# PDF functionality, you can download IronPDF and use it free for development in your project. Either install from a <a href="https://ironpdf.com/packages/IronPdf.Package.For.Dotnet.PDF.zip" target="_blank">ZIP DLL Download</a> or use the package via <a href="https://www.nuget.org/packages/IronPdf" target="_blank" rel="nofollow">NuGet install</a>. You can even convert an ASP .NET to PDF in just one line of code.

Here is an example:

**C#:**
```cs
using System;
using System.Web.UI;
using IronPdf;
namespace aspxtopdf
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            AspxToPdf.RenderThisPageAsPdf();
        }
    }
}
```
**VB:**
```vb
Imports System
Imports System.Web.UI
Imports IronPdf
Namespace aspxtopdf
	Partial Public Class _Default
		Inherits Page
		Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
		End Sub
		Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
			AspxToPdf.RenderThisPageAsPdf()
		End Sub
	End Class
End Namespace
```

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/711qky0p5wct2wmosngz.png)

## 10. Generate PDF Document

Install the IronPDF C# HTML to PDF library. Access the software by [direct file download](https://ironpdf.com/packages/IronPdf.Package.For.Generate.PDF.Documents.zip) or through the latest <a href="https://www.nuget.org/packages/IronPdf" target="_blank" rel="nofollow">NuGet Package install</a> to load into Visual Studio and your project. The IronPDF library simplifies PDF tasks into easy-to-use and understandable .NET methods.

Firstly, Speed! Not only does IronPDF generate PDF files for .NET quicker, but it also increases developer productivity because of the easy naming convention employed for methods in the IronPDF .NET PDF library.

Secondly, ease of use! As mentioned previously, the IronPDF .NET PDF library is very easy to work with. It is easy to identify method names and understand their purpose. .NET developers will not struggle to get generate PDF in .NET with this pdf library in either VB.NET or C#.

Here is a very quick example of how to generate a PDF from an HTML input string:

**C#:**
```cs
/**
PDF from HTML String
anchor-generate-pdf-from-html-string
**/
private void HTMLString()
        {
            // Render any HTML fragment or document to HTML
            var Renderer = new IronPdf.ChromePdfRenderer();
            var PDF = Renderer.RenderHtmlAsPdf("<h1>Hello IronPDF</h1>");
            var OutputPath = "ChromePdfRenderer.pdf";
            PDF.SaveAs(OutputPath);
        }
```
**VB:**
```vb
'''
'''PDF from HTML String
'''anchor-generate-pdf-from-html-string
'''*
Private Sub HTMLString()
			' Render any HTML fragment or document to HTML
			Dim Renderer = New IronPdf.ChromePdfRenderer()
			Dim PDF = Renderer.RenderHtmlAsPdf("<h1>Hello IronPDF</h1>")
			Dim OutputPath = "ChromePdfRenderer.pdf"
			PDF.SaveAs(OutputPath)
End Sub
```

The following code makes use of IronPDF to generate a PDF directly from an ASPX file:

**C#:**
```cs
/**
PDF from ASPX
anchor-generate-pdf-from-aspx
**/
protected void Page_Load(object sender, EventArgs e)
        {
            IronPdf.AspxToPdf.RenderThisPageAsPdf();
        }
```
**VB:**
```vb
'''
'''PDF from ASPX
'''anchor-generate-pdf-from-aspx
'''*
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
			IronPdf.AspxToPdf.RenderThisPageAsPdf()
End Sub
```

IronPDF supports JavaScript quite nicely via the Chromium rendering engine. One stipulation though, you may have to add a delay to a page render to allow JavaScript time to execute whilst generating PDFs.

## 11. PDF Library for .NET

Using IronPDF, we're able to create and edit PDF features in a simple manner according to our application requirements. IronPDF provides a suite of functionality with its C# .NET PDF Library and provides it free for developers to experiment and optimize their projects before deployment. The two main ways of accessing the library are to either:

<ol>
  <li>Download and unpack the <a href="https://ironpdf.com/packages/IronPdf.Package.For.PDF.NET.Library.zip">DLL file</a></li>
  <li>Navigate <a href="https://www.nuget.org/packages/IronPdf" target"_blank">NuGet</a> and install the package via Visual Studio</li>
</ol>

In the code below, we have used a C# Form demonstrating simply how to create a PDF with C#:

**C#:**
```cs
using IronPdf;
using System.Windows.Forms;
namespace readpdf
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, System.EventArgs e)
        {
            //Used ChromePdfRenderer Convert Class
            var HtmlLine = new ChromePdfRenderer();
            //Getting Text from TextBox
            string text = textBox1.Text;
            //Here we are rendering or converting htmlaspdf.
            HtmlLine.RenderHtmlAsPdf("<h1>"+text+"</h1>").SaveAs("custom.pdf");
            //Confirmation
            MessageBox.Show("Done !");
        }
    }
}
```
**VB:**
```vb
Imports IronPdf
Imports System.Windows.Forms
Namespace readpdf
	Partial Public Class Form1
		Inherits Form
		Public Sub New()
			InitializeComponent()
		End Sub
		Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
			'Used ChromePdfRenderer Convert Class
			Dim HtmlLine = New ChromePdfRenderer()
			'Getting Text from TextBox
'INSTANT VB NOTE: The variable text was renamed since Visual Basic does not handle local variables named the same as class members well:
			Dim text_Conflict As String = textBox1.Text
			'Here we are rendering or converting htmlaspdf.
			HtmlLine.RenderHtmlAsPdf("<h1>" & text_Conflict &"</h1>").SaveAs("custom.pdf")
			'Confirmation
			MessageBox.Show("Done !")
		End Sub
	End Class
End Namespace
```
**C# Form:**

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r6w4m7clgjjdyf5en5kd.png)

## 12. Chrome PDF Rendering Engine

The Iron Software engineering team is proud to release a game-changing upgrade to IronPDF in 2021, now featuring **“Chrome Identical” PDF rendering**

First you must install IronPDF into your project from the Nuget Package Manager named IronPdf. Changing to the new renderer at a global level is simple. This approach updates all usages of your existing _ChromePdfRenderer_ and _AspxToPdf_ code.

Some of the Features of Chrome Pdf Rendering Feature are:
<ol>
  <li><strong>High-Quality Rendering</strong>
    <ol>
      <li>The latest "Blink!" HTML rendering. Choose from <strong>Chrome Identical rendering</strong> or Enhanced Rendering</li>
    </ol>
  </li>
  <li><strong>20% Faster Renders</strong>
    <ol>
      <li>Provides effortless multithreading and Async, using as many CPU cores as you wish. For SAAS and high-load applications, this may be <strong>5-20 times faster</strong>, outperforming direct browser usage and web-drivers.</li>
    </ol>
  </li>
  <li><strong>Full Support</strong>
    <ol>
      <li>Full (and we mean full) support for <strong>JavaScript, responsive</strong> layout and <strong>CSS3</strong>.</li>
      <li><strong>Azure</strong> as a first-class citizen. It just works.</li>
      <li>Continued maintenance and improved full support for .NET 5, Core, and Framework 4.0+.</li>
    </ol>
  </li>
  <li><strong>Rigorously Tested</strong>
    <ol>
      <li>The release passed with <strong>1156 green units & integration tests</strong> (and no red ones). We believe this EAP to be as stable as our main release, and it has our best minds actively improving it every day.</li>
    </ol>
  </li>
  <li><strong>Section 508 Accessibility Compliance</strong></li>
</ol>

Produces accessible PDFs using the PDF(UA) tagged PDF standard.

You can use the IronPdf.Rendering.AdaptivePdfRenderer to switch between the ‘Chrome’ and ‘WebKit’ rendering in an instance. If you preferred the old rendering style for some of your applications, or don't want to break unit tests. Multithreading and Async support for our Chrome rendering engine is in a different league to the previous build.

<ol>
  <li>For enterprise-grade multi-threading, use our <em>ChromePdfRenderer</em> in your existing threads and it will work. For web applications, this also takes zero setup.</li>
  <li>For batch processing of HTML to PDF, we recommend using the built-in .NET <em>Parallel.ForEach</em> pattern.</li>
  <li>We love async and have provided Async variants of all of our rendering methods such as <em>ChromePdfRenderer.RenderHtmlAsPdfAsync</em></li>
</ol>

Here is an example:

**C#:**
```cs
IChromePdfRenderer Renderer = new ChromePdfRenderer();
            Renderer.RenderingOptions.FitToPaper = true;
            Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Screen;
            Renderer.RenderingOptions.PrintHtmlBackgrounds = true;
            Renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
            var doc = Renderer.RenderHtmlAsPdf("<h1>Hello world! This is sample for IronPdf</h1>");
            doc.SaveAs("google_chrome.pdf");
```
**VB:**
```vb
Dim Renderer As IChromePdfRenderer = New ChromePdfRenderer()
			Renderer.RenderingOptions.FitToPaper = True
			Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Screen
			Renderer.RenderingOptions.PrintHtmlBackgrounds = True
			Renderer.RenderingOptions.CreatePdfFormsFromHtml = True
			Dim doc = Renderer.RenderHtmlAsPdf("<h1>Hello world! This is sample for IronPdf</h1>")
			doc.SaveAs("google_chrome.pdf")
```

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fa4vogqhyraw04se5w9v.png)

## Summary

Thanks for reading! In this article, we have learned how to create a PDF document in C# using IronPDF. IronPDF is ideal for users needing to convert the contents of HTML to PDF without using HTML tags because of its ease of use and additional features like using JavaScript, CSS, and images.

So, try out these methods and leave your feedback in the comments section of this article post! If you are not yet an IronPDF customer, you can try 30-day <a href="https://www.syncfusion.com/downloads" target="_blank" rel="nofollow">free trial</a> to check their available features.

If you buy the complete Iron Suite, you will get all 5 Products for the Price of 2. For further details about the <a href="https://ironsoftware.com/csharp/ocr/licensing/" target="_blank">licensing</a>, please follow this <a href="https://ironsoftware.com/suite/" target="_blank>link</a> to purchase the complete package.

---