PDF Converter .NET (Developer Tutorial)

1.0 Introduction

Adobe created the Portable Document Format (PDF) to allow documents to be viewed and exchanged between different computers easily. PDF files are widely used in modern society, with many different types of organizations using PDF files for tasks such as documents and invoices. To fulfil client requests, developers often need to provide documents in PDF format. Thanks to modern libraries, creating PDFs is now simpler than ever. When choosing which library to add to a project, one must take features like build, read, and conversion abilities into account in order to select the best one available.

2.0 IronPDF Features

IronPDF is a PDF library that enables developers to quickly create, read, and edit PDF documents. It is a powerful PDF converter and API library for PDF processing. The IronPDF net package uses the Chrome engine to convert HTML to PDF. The library supports many web components, including Xamarin, Blazor, Unity, HoloLens applications, Windows Forms, HTML, ASPX, Razor HTML, NET Core, ASP.NET, Windows Forms, and WPF. Both ASP.NET web applications and traditional Windows applications can use Microsoft.NET and .NET Core apps. With IronPDF, it is possible to create visually appealing PDFs with a title and footer using HTML5, JavaScript, CSS, and images. The API library includes a powerful HTML-to-PDF converter that integrates well with PDF, as well as a stand-alone PDF conversion engine that is independent of any external resources.

  • The IronPDF library supports the creation of PDFs from various sources, including image files, HTML, HTML5, ASPX, and Razor/MVC View.
  • The library provides capabilities for producing interactive PDF files, completing and submitting interactive forms, combining multiple PDF files into one, splitting PDF files, extracting text and images, searching text, and rasterizing PDF pages to images.
  • The library allows the use of a link as the basis of a PDF document and supports user agents, proxies, cookies, HTTP headers, and form variables for authentication behind HTML login forms.
  • IronPDF enables access to protected PDF files by supplying user names and passwords.
  • The library supports the reading and editing of existing PDF documents.
  • Users can add text, graphics, bookmarks, watermarks, headers, and footers to PDF documents with IronPDF, and extract images from PDF files.
  • IronPDF allows for splitting and merging pages in a new or existing PDF document and can produce PDF objects from text without the need for Adobe Acrobat Reader.
  • CSS media files and CSS files can both be converted to PDF documents with IronPDF.
  • Users can add new PDF forms or complete existing ones with IronPDF.
  • IronPDF can also convert PDF pages into various image formats such as JPEG, PNG, etc.

3.0 Create PDF Documents from URLs

Generating PDF files from web pages is easy with IronPDF's built-in Chrome browser and API library. Simply provide the URL and convert it to a PDF file using the IronPDF API library. Document conversion can be completed quickly with just a few lines of code:


var Renderer = new IronPdf.ChromePdfRenderer().RenderUrlAsPdf("https://www.google.co.in/").SaveAs("result.pdf");

var Renderer = new IronPdf.ChromePdfRenderer().RenderUrlAsPdf("https://www.google.co.in/").SaveAs("result.pdf");
Dim Renderer = (New IronPdf.ChromePdfRenderer()).RenderUrlAsPdf("https://www.google.co.in/").SaveAs("result.pdf")
VB   C#

We can use the RenderUrlAsPdf method to quickly convert a URL into a PDF document. Simply provide the URL and the desired save location, and IronPDF will generate the PDF file according to the information provided above. This makes it easy to convert web pages into PDF documents with just a few lines of code.

PDF Converter .NET (Developer Tutorial): Figure 1

4.0 Create a PDF from HTML Strings

HTML strings can be quickly converted into PDF files using the IronPDF API library. The following code snippet can turn HTML strings into documents and can translate any HTML tag into a PDF file.


var Renderer = new IronPdf.ChromePdfRenderer().RenderHtmlAsPdf("Hello world!!").SaveAs("result.pdf");

var Renderer = new IronPdf.ChromePdfRenderer().RenderHtmlAsPdf("Hello world!!").SaveAs("result.pdf");
Dim Renderer = (New IronPdf.ChromePdfRenderer()).RenderHtmlAsPdf("Hello world!!").SaveAs("result.pdf")
VB   C#

This code snippet illustrates how to use the RenderHtmlAsPdf function to convert HTML text into a PDF. The function that converts HTML into a string accepts as much HTML code as we want. Once we have the string, we can quickly and easily complete the process by using the "save as" feature to save the document.

PDF Converter .NET (Developer Tutorial): Figure 2

5.0 Create a PDF File from an HTML File

The IronPDF API library allows for the rapid conversion of HTML files into PDF files. Any HTML tag may be converted into a PDF file using the following sample code.


var Renderer = new IronPdf.ChromePdfRenderer().RenderHtmlFileAsPdf("test.html").SaveAs("result.pdf");

var Renderer = new IronPdf.ChromePdfRenderer().RenderHtmlFileAsPdf("test.html").SaveAs("result.pdf");
Dim Renderer = (New IronPdf.ChromePdfRenderer()).RenderHtmlFileAsPdf("test.html").SaveAs("result.pdf")
VB   C#

The HTML text is as below:


< style="color:red">Hello world

< style="color:red">Hello world
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'< style="color:red"> Hello world
VB   C#

PDF Converter .NET (Developer Tutorial): Figure 3

6.0 Create a PDF File from a Rich Text File

The IronPDF API library also allows for fast PDF creation from Rich Text Files (RTFs). The sample code for converting RTFs to PDFs can be utilized to convert any number of RTFs into a single PDF file. The code is provided below.


var Renderer = new IronPdf.ChromePdfRenderer().RenderRtfFileAsPdf("test.html").SaveAs("result.pdf");

var Renderer = new IronPdf.ChromePdfRenderer().RenderRtfFileAsPdf("test.html").SaveAs("result.pdf");
Dim Renderer = (New IronPdf.ChromePdfRenderer()).RenderRtfFileAsPdf("test.html").SaveAs("result.pdf")
VB   C#

PDF Converter .NET (Developer Tutorial): Figure 4

In the image above, the left side shows the source document, while the right side displays the PDF file after conversion. Additionally, we can utilize the RTF string to create a PDF by using the code provided below.


var Renderer = new IronPdf.ChromePdfRenderer().RenderRtfStringAsPdf("{/rtf..}").SaveAs("result.pdf");

var Renderer = new IronPdf.ChromePdfRenderer().RenderRtfStringAsPdf("{/rtf..}").SaveAs("result.pdf");
Dim Renderer = (New IronPdf.ChromePdfRenderer()).RenderRtfStringAsPdf("{/rtf..}").SaveAs("result.pdf")
VB   C#

7.0 Create a PDF File from a Markdown File

Quick PDF production from markdown files is possible thanks to the IronPDF API module. Any number of Markdown files can be converted into a PDF file using the sample code for the conversion, shown below.


var Renderer = new IronPdf.ChromePdfRenderer().RenderMarkdownFileAsPdf("Markdown.md").SaveAs("Markdown_result.pdf");

var Renderer = new IronPdf.ChromePdfRenderer().RenderMarkdownFileAsPdf("Markdown.md").SaveAs("Markdown_result.pdf");
Dim Renderer = (New IronPdf.ChromePdfRenderer()).RenderMarkdownFileAsPdf("Markdown.md").SaveAs("Markdown_result.pdf")
VB   C#

PDF Converter .NET (Developer Tutorial): Figure 5

As shown in the image above, the source document is on the left, and the converted PDF file is on the right. The code provided below enables the conversion of an MD string to a PDF. For further information on HTML conversion using IronPDF, please visit this link.


var Renderer = new IronPdf.ChromePdfRenderer().RenderMarkdownStringAsPdf("Hello world Hello world").SaveAs("Markdown_result.pdf");

var Renderer = new IronPdf.ChromePdfRenderer().RenderMarkdownStringAsPdf("Hello world Hello world").SaveAs("Markdown_result.pdf");
Dim Renderer = (New IronPdf.ChromePdfRenderer()).RenderMarkdownStringAsPdf("Hello world Hello world").SaveAs("Markdown_result.pdf")
VB   C#

For more information on how to use the IronPDF API library, refer to the code tutorial here.

8.0 Conclusion

The IronPDF library provides a free license for development, and depending on the developer's needs, several licenses are available for purchase for use in a production environment. The Lite bundle has an initial price of $499 and has no ongoing costs. The licenses come with a permanent license, a 30-day money-back guarantee, a year of product support and upgrades, as well as the possibility of redistribution for SaaS and OEM. They are one-time purchases that can be used for development, staging, and production. IronPDF also offers additional time-limited free licenses and free licenses for redistribution protection. For a complete overview of pricing and licensing information for IronPDF, please click here.