Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
Generating PDF documents programmatically can be complex due to its complexity, especially when they include images, tables, text, formatting, and other features.
The main challenge is to figure out how to convert a plain text document into a PDF format. Numerous methods can be used, but choosing one that will maintain the formatting of the original document is essential.
In this tutorial, I'll compare Progress Software Corporation's Telerik PdfProcessing library with Iron Software's IronPDF in how well both can generate PDF documents.
Import
method to load existing HTML file in C#Export
methodTelerik PdfProcessing Documentation, part of Progress's portfolio of document processing applications, allows you to create PDFs and export them without writing any code. It has features such as text blocks, images, forms, tables, import, and export. In addition, the library offers features that are perfect for flow-like editing. The PdfProcessing app is available for web, desktop, and mobile platforms.
IronPDF is a .NET PDF library that can generate PDFs without requiring Adobe Acrobat or other third-party software. The library can create PDFs from scratch or export existing .NET components (like ASP.NET official site web pages, WPF user interfaces, etc.) into PDF files.
In this section, I'll cover how we can install IronPDF and Telerik Document Processing libraries.
To create a PDF document from HTML using the Telerik Document Processing suite, we have to install three libraries:
You can install the following libraries using the NuGet Package Manager.
You can install IronPDF using three ways:
For installation with the Package Manager Console, you'll need to write the following command in the console.
Install-Package IronPdf
It'll install the latest IronPDF library version in the project. Of course, you can always check the newest version of IronPDF on the IronPDF's NuGet page.
Telerik supports converting HTML to PDF using the RadFlowDocument
library addon. It can convert an HTML document containing an HTML string to a PDF document.
You can use the following code for converting HTML to PDF using Telerik.
using Telerik.Windows.Documents.Flow.FormatProviders.Html;
using Telerik.Windows.Documents.Flow.Model;
HtmlFormatProvider htmlProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider();
// Create a document instance from the content.
RadFlowDocument document = htmlProvider.Import(File.ReadAllText(@"C:\HTML Website\website\index.html"));
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider pdfProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
// Export the document. The different overloads enable you to export to a byte [] or to a Stream.
byte [] pdfBytes = pdfProvider.Export(document);
File.WriteAllBytes(@"C:/test.pdf", pdfBytes);
using Telerik.Windows.Documents.Flow.FormatProviders.Html;
using Telerik.Windows.Documents.Flow.Model;
HtmlFormatProvider htmlProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider();
// Create a document instance from the content.
RadFlowDocument document = htmlProvider.Import(File.ReadAllText(@"C:\HTML Website\website\index.html"));
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider pdfProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
// Export the document. The different overloads enable you to export to a byte [] or to a Stream.
byte [] pdfBytes = pdfProvider.Export(document);
File.WriteAllBytes(@"C:/test.pdf", pdfBytes);
Imports Telerik.Windows.Documents.Flow.FormatProviders.Html
Imports Telerik.Windows.Documents.Flow.Model
Private htmlProvider As HtmlFormatProvider = New Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider()
' Create a document instance from the content.
Private document As RadFlowDocument = htmlProvider.Import(File.ReadAllText("C:\HTML Website\website\index.html"))
Private pdfProvider As New Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider()
' Export the document. The different overloads enable you to export to a byte [] or to a Stream.
Private pdfBytes() As Byte = pdfProvider.Export(document)
File.WriteAllBytes("C:/test.pdf", pdfBytes)
The above code is somewhat complex. You'll first need to create an HtmlFormatProvider
and a RadFlowDocument
. Import HTML file using the Import
function of the HtmlFormatProvider
, and use the returned RadFlowDocument
object to produce a PdfFormatProvider
. At last, use the WriteAllBytes
method on the PdfFormatProvider
to export the PDF file to a specific location.
The output generated by Telerik is not good. Telerik didn't retain the UI of the HTML document or load any of the images.
IronPDF can generate PDF using HTML files, HTML strings, and URLs.
Use the following code to create a PDF document using an HTML file.
using IronPdf;
var IronRenderer = new ChromePdfRenderer();
IronRenderer.RenderingOptions.FitToPaperMode = IronPdf.Engines.Chrome.FitToPaperModes.FixedPixelWidth;
var pdfFromHtmlFile = IronRenderer.RenderHtmlFileAsPdf(@"C:\HTML Website\website\index.html");
pdfFromHtmlFile.SaveAs(@"C:/IronPDF Test.pdf");
using IronPdf;
var IronRenderer = new ChromePdfRenderer();
IronRenderer.RenderingOptions.FitToPaperMode = IronPdf.Engines.Chrome.FitToPaperModes.FixedPixelWidth;
var pdfFromHtmlFile = IronRenderer.RenderHtmlFileAsPdf(@"C:\HTML Website\website\index.html");
pdfFromHtmlFile.SaveAs(@"C:/IronPDF Test.pdf");
Imports IronPdf
Private IronRenderer = New ChromePdfRenderer()
IronRenderer.RenderingOptions.FitToPaperMode = IronPdf.Engines.Chrome.FitToPaperModes.FixedPixelWidth
Dim pdfFromHtmlFile = IronRenderer.RenderHtmlFileAsPdf("C:\HTML Website\website\index.html")
pdfFromHtmlFile.SaveAs("C:/IronPDF Test.pdf")
I use the RenderHtmlFileAsPdf
method to generate PDF from the HTML file. This function reads all content from the HTML file, loading the related CSS and JavaScript files. The output of the RenderHtmlFileAsPdf
method is below.
IronPDF generates PDF from HTML very beautifully. This result is different and better than the Telerik-generated PDF.
You can use the following code to generate PDF from the URL.
using IronPdf.Rendering;
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.PaperSize = PdfPaperSize.A2;
PdfDocument myPdf = renderer.RenderUrlAsPdf("https://dotnet.microsoft.com/en-us/");
myPdf.SaveAs(@"C:/dotnet.pdf");
using IronPdf.Rendering;
using IronPdf;
ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.PaperSize = PdfPaperSize.A2;
PdfDocument myPdf = renderer.RenderUrlAsPdf("https://dotnet.microsoft.com/en-us/");
myPdf.SaveAs(@"C:/dotnet.pdf");
Imports IronPdf.Rendering
Imports IronPdf
Private renderer As New ChromePdfRenderer()
renderer.RenderingOptions.PaperSize = PdfPaperSize.A2
Dim myPdf As PdfDocument = renderer.RenderUrlAsPdf("https://dotnet.microsoft.com/en-us/")
myPdf.SaveAs("C:/dotnet.pdf")
The RenderUrlAsPdf
function converts a webpage's URL into a PDF. It waits to load all related files before rendering. It produces extraordinary results. It preserves all colors, designs, and UI. You can see the output below.
You can get more tutorials about IronPDF and see them in action on the IronPDF Tutorial Page.
As we've seen the output UI for ASP.NET results of IronPDF and Telerik, we can say that Telerik is not a good option for HTML to PDF conversions, as its rendering quality is not good. You can see the difference between the outputs of IronPDF and Telerik below.
In the above image, you can see the clear difference between the standard outputs of IronPDF and Telerik. Let's compare the output on the basis of features.
The rendering quality of Telerik is poor. The PDFs that it renders have poor formatting, failing to preserve the original styles of the document. On the other hand, IronPDF has outstanding rendering quality, retaining every aspect of the source document.
Telerik doesn't support external files. Moreover, it doesn't support JavaScript.
Conversely, IronPDF has full support for internal and external CSS and JavaScript declarations. Processing of JavaScript can be toggled on or off as required with IronPDF.
In summation, following are some additional limitations of Telerik PdfProcessing:
IronPDF's chief features are:
There are many other features of IronPDF. You can visit the IronPDF Features Page for the best information.
In this article, we compared IronPDF with Telerik PdfDocument Processing libraries and find that IronPDF is far better than the Telerik library for the HTML to PDF conversion.
IronPDF is an excellent library for all PDF-related operations. You can create, edit and modify PDF files in all the latest .NET and .NET Core frameworks. Visit the IronPDF Licensing Page for more information about the distribution and licensing of IronPDF product bundles.
9 .NET API products for your office documents