USING IRONPDF

PDF Converter .NET (Developer Tutorial)

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:

// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified URL to a PDF
var pdf = renderer.RenderUrlAsPdf("https://www.google.co.in/");

// Save the PDF to the specified path
pdf.SaveAs("result.pdf");
// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified URL to a PDF
var pdf = renderer.RenderUrlAsPdf("https://www.google.co.in/");

// Save the PDF to the specified path
pdf.SaveAs("result.pdf");
$vbLabelText   $csharpLabel

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.

// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified HTML string to a PDF
var pdf = renderer.RenderHtmlAsPdf("<p>Hello world!!</p>");

// Save the PDF to the specified path
pdf.SaveAs("result.pdf");
// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified HTML string to a PDF
var pdf = renderer.RenderHtmlAsPdf("<p>Hello world!!</p>");

// Save the PDF to the specified path
pdf.SaveAs("result.pdf");
$vbLabelText   $csharpLabel

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 the process can be quickly and easily completed 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.

// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified HTML file to a PDF
var pdf = renderer.RenderHtmlFileAsPdf("test.html");

// Save the PDF to the specified path
pdf.SaveAs("result.pdf");
// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified HTML file to a PDF
var pdf = renderer.RenderHtmlFileAsPdf("test.html");

// Save the PDF to the specified path
pdf.SaveAs("result.pdf");
$vbLabelText   $csharpLabel

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.

// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified RTF file to a PDF
var pdf = renderer.RenderRtfFileAsPdf("test.rtf");

// Save the PDF to the specified path
pdf.SaveAs("result.pdf");
// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified RTF file to a PDF
var pdf = renderer.RenderRtfFileAsPdf("test.rtf");

// Save the PDF to the specified path
pdf.SaveAs("result.pdf");
$vbLabelText   $csharpLabel

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.

// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified RTF string to a PDF
var pdf = renderer.RenderRtfStringAsPdf("{\\rtf1...}");

// Save the PDF to the specified path
pdf.SaveAs("result.pdf");
// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified RTF string to a PDF
var pdf = renderer.RenderRtfStringAsPdf("{\\rtf1...}");

// Save the PDF to the specified path
pdf.SaveAs("result.pdf");
$vbLabelText   $csharpLabel

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.

// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified Markdown file to a PDF
var pdf = renderer.RenderMarkdownFileAsPdf("Markdown.md");

// Save the PDF to the specified path
pdf.SaveAs("Markdown_result.pdf");
// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified Markdown file to a PDF
var pdf = renderer.RenderMarkdownFileAsPdf("Markdown.md");

// Save the PDF to the specified path
pdf.SaveAs("Markdown_result.pdf");
$vbLabelText   $csharpLabel

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 HTML to PDF Conversion Tutorial.

// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified Markdown string to a PDF
var pdf = renderer.RenderMarkdownStringAsPdf("# Hello world\n\nHello world");

// Save the PDF to the specified path
pdf.SaveAs("Markdown_result.pdf");
// Create a new instance of the ChromePdfRenderer class
var renderer = new IronPdf.ChromePdfRenderer();

// Convert the specified Markdown string to a PDF
var pdf = renderer.RenderMarkdownStringAsPdf("# Hello world\n\nHello world");

// Save the PDF to the specified path
pdf.SaveAs("Markdown_result.pdf");
$vbLabelText   $csharpLabel

For more information on how to use the IronPDF API library, refer to the developer documentation IronPDF Documentation Resource.

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 IronPDF Licensing Information Page.

Frequently Asked Questions

What is IronPDF?

IronPDF is a powerful PDF library that enables developers to create, read, and edit PDF documents from various sources such as HTML, Markdown, and RTF files.

What features does IronPDF offer?

IronPDF offers features such as HTML to PDF conversion using the Chrome engine, creation of interactive PDF files, text and image extraction, text searching, rasterizing PDF pages into images, and support for various inputs like image, HTML5, ASPX, and Razor/MVC View conversions.

How do you convert a URL to a PDF using IronPDF?

You can convert a URL to a PDF using IronPDF by creating a new instance of the ChromePdfRenderer class and using the RenderUrlAsPdf method to quickly generate a PDF document from a URL.

Can IronPDF convert HTML strings to PDF?

Yes, IronPDF can convert HTML strings to PDF using the RenderHtmlAsPdf function, which translates HTML tags into a PDF document.

Is it possible to convert HTML files to PDF with IronPDF?

Yes, IronPDF allows for the rapid conversion of HTML files into PDF files using the RenderHtmlFileAsPdf method.

How can RTF files be converted to PDF using IronPDF?

RTF files can be converted to PDF using IronPDF by utilizing the RenderRtfFileAsPdf method, which enables fast PDF creation from Rich Text Files.

Can IronPDF convert Markdown files to PDF?

Yes, IronPDF can convert Markdown files to PDF using the RenderMarkdownFileAsPdf method, allowing quick PDF production from markdown files.

What licensing options are available for IronPDF?

IronPDF provides a free license for development and several licenses for production use, including the Lite bundle. Licenses are one-time purchases with a permanent license, a 30-day money-back guarantee, and a year of product support and upgrades.

Does IronPDF support protected PDF files?

Yes, IronPDF enables access to protected PDF files with passwords by supplying usernames and passwords, allowing users to read and edit existing protected PDF documents.

What kind of applications can use IronPDF?

IronPDF can be used with both ASP.NET Web Applications and traditional Windows Applications, supporting a wide range of web components for PDF creation and editing.

Chipego
Software Engineer
Chipego has a natural skill for listening that helps him to comprehend customer issues, and offer intelligent solutions. He joined the Iron Software team in 2023, after studying a Bachelor of Science in Information Technology. IronPDF and IronOCR are the two products Chipego has been focusing on, but his knowledge of all products is growing daily, as he finds new ways to support customers. He enjoys how collaborative life is at Iron Software, with team members from across the company bringing their varied experience to contribute to effective, innovative solutions. When Chipego is away from his desk, he can often be found enjoying a good book or playing football.
< PREVIOUS
ASP PDF Viewer (Developer Tutorial)
NEXT >
How to Crop PDF File in C#