USING IRONPDF

PDF Converter .NET (Developer Tutorial)

Updated April 19, 2023
Share:

1.0 Introduction

Adobe's Portable Document Format (PDF) is widely used for document viewing and exchange. Developers often need to create PDFs to meet client needs, and modern libraries have simplified this process. When selecting a library for a project, it's important to consider features like build, read, and conversion capabilities.

2.0 IronPDF Features

IronPDF is a versatile library for creating, reading, and editing PDF documents, with capabilities to convert HTML to PDF using the Chrome engine. It supports a wide range of web components and can be used with both ASP.NET Web Applications and traditional Windows Applications. The library allows the creation of visually appealing PDFs using HTML5, JavaScript, CSS, and images, and includes a powerful HTML-to-PDF converter.

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#

The RenderUrlAsPdf method can be used 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: The generated PDF file from a Google URL The generated PDF file from a Google URL

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 needed. Then can quickly and easily complete the process by using the SaveAs feature to save the document.

PDF Converter .NET (Developer Tutorial), Figure 2: The output PDF file from an HTML string The output PDF file from an HTML string

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:

<p style="color:red">Hello world</p>
<p style="color:red">Hello world</p>
HTML

PDF Converter .NET (Developer Tutorial), Figure 3: The output PDF file from an HTML file The output PDF file from an HTML file

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.rtf").SaveAs("result.pdf");
var renderer = new IronPdf.ChromePdfRenderer().RenderRtfFileAsPdf("test.rtf").SaveAs("result.pdf");
Dim renderer = (New IronPdf.ChromePdfRenderer()).RenderRtfFileAsPdf("test.rtf").SaveAs("result.pdf")
VB   C#

PDF Converter .NET (Developer Tutorial), Figure 4: The output PDF file from an RTF file The output PDF file from an RTF file

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: The output PDF file from a Markdown file The output PDF file from a Markdown file

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 $749 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 visit the licensing page.

< PREVIOUS
ASP PDF Viewer (Developer Tutorial)
NEXT >
How to Crop PDF File in C#

Ready to get started? Version: 2024.6 just released

Start Free Trial Total downloads: 9,580,872
View Licenses >