Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
PDF stands for Portable Document Format, a file format that can display text and static images. PDF files can also be printed, converted to HTML, or sent to an online fax service to send over the internet.
PDF files are important as they protect information and are easier to share than other file formats such as DOCX, PPTX, or XLSX. These are usually edited in word processing programs or spreadsheet programs.
A PDF document preserves the integrity of its content as the formatting does not change when opened on other devices. A PDF document cannot be changed unless you have access to the original file from which it was created. This means that there are no risks of accidentally editing, deleting, or altering its contents without the user's knowledge. The PDF document is in the public domain, meaning that anyone can download and read it without any legal issues. PDFs are becoming increasingly important in our digital world due to their ability to store information in a single document that can be shared at any time.
In this article, we will compare two .NET PDF libraries:
IronPDF - A Powerful .NET PDF Library is a .NET library that helps create and read PDF documents, as well as provides the tools to manage and adapt PDF documents. IronPDF is a library that hosts building functions for creating, reading, and manipulating PDF files with only a few lines of code.
The following article will show you how to create PDF files with IronPDF. This tutorial assumes that you already know the basics of C#, Visual Studio, and that you possess a working knowledge of HTML.
We need Visual Studio for writing, compiling, and running our application, C# for writing logic and code, and HTML for formatting PDF files such as making titles, headings, adding images, paragraphs, etc. This library fully supports .NET Core, .NET 5, Framework, and Standard.
We can create a PDF file in C# with only a few lines of code. This is a very easy task that only requires basic knowledge of C# and HTML. This detailed overview of IronPDF will help you learn more about its features.
We first need to install the IronPDF NuGet Package to develop a solution. From the Menu Bar, select "Project" and a drop-down list will appear. Select "Manage IronPDF NuGet Packages" from the drop-down menu. The window below will display:
Select the "Browse" tab:
In the input box, search 'IronPdf':
Select IronPdf:
Press the 'Install' button and wait for the installation to finish. The following window will appear after a successful installation:
Once you have pressed the 'OK' button, you're ready to go.
Add the namespace IronPDF Namespace Guide at the top of the file.
using IronPdf;
using IronPdf;
Imports IronPdf
We need a file path to save our newly created PDF. The SaveFileDialog
object is used towards this end. It will ask the user to select a file path and file name.
private void Save_Click(object sender, EventArgs e)
{
// Selects the folder to save the file.
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory = @"D:\";
saveFileDialog1.Title = "Save Pdf File";
saveFileDialog1.DefaultExt = "pdf";
saveFileDialog1.Filter = "Pdf files (*.pdf)|*.pdf|All files (*.*)|*.*";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
string filename = saveFileDialog1.FileName;
// Creates the PDF files
var HtmlLine = new HtmlToPdf();
HtmlLine.RenderHtmlAsPdf(PdfText.Text).SaveAs(filename);
// Message displays that file has saved
MessageBox.Show("File Saved Successfully!");
}
}
private void Save_Click(object sender, EventArgs e)
{
// Selects the folder to save the file.
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory = @"D:\";
saveFileDialog1.Title = "Save Pdf File";
saveFileDialog1.DefaultExt = "pdf";
saveFileDialog1.Filter = "Pdf files (*.pdf)|*.pdf|All files (*.*)|*.*";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
string filename = saveFileDialog1.FileName;
// Creates the PDF files
var HtmlLine = new HtmlToPdf();
HtmlLine.RenderHtmlAsPdf(PdfText.Text).SaveAs(filename);
// Message displays that file has saved
MessageBox.Show("File Saved Successfully!");
}
}
Private Sub Save_Click(ByVal sender As Object, ByVal e As EventArgs)
' Selects the folder to save the file.
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.InitialDirectory = "D:\"
saveFileDialog1.Title = "Save Pdf File"
saveFileDialog1.DefaultExt = "pdf"
saveFileDialog1.Filter = "Pdf files (*.pdf)|*.pdf|All files (*.*)|*.*"
saveFileDialog1.FilterIndex = 2
saveFileDialog1.RestoreDirectory = True
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
Dim filename As String = saveFileDialog1.FileName
' Creates the PDF files
Dim HtmlLine = New HtmlToPdf()
HtmlLine.RenderHtmlAsPdf(PdfText.Text).SaveAs(filename)
' Message displays that file has saved
MessageBox.Show("File Saved Successfully!")
End If
End Sub
In the code example, SaveFileDialog will open a file dialog to select the folder and file name to store the PDF file. The Initial Directory is set to the D drive. The Default Extension is set to PDF files, as we are only dealing with PDF files here.
The "if" statement contains all the code that will create the PDF document. This only takes two lines of code to generate a PDF file. PDFText is the name of a Rich Text box that contains the content that will be written in a PDF document. The filename is the file path and name which was set by the user via SaveFileDialog
.
The code for reading PDF documents can be complex, difficult, and confusing to code and understand. Don’t worry — IronPDF has made it easier and simpler! Reading PDF files only takes two lines of code.
At the top of the file, add the following code to import the IronPDF Reading PDFs Guide library.
using IronPdf;
using System;
using System.Windows.Forms;
using IronPdf;
using System;
using System.Windows.Forms;
Imports IronPdf
Imports System
Imports System.Windows.Forms
Inside the function, add the code:
private void Read_Click(object sender, EventArgs e)
{
PdfDocument PDF = PdfDocument.FromFile(FilePath.Text);
FileContent.Text = PDF.ExtractAllText();
}
private void Read_Click(object sender, EventArgs e)
{
PdfDocument PDF = PdfDocument.FromFile(FilePath.Text);
FileContent.Text = PDF.ExtractAllText();
}
Private Sub Read_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim PDF As PdfDocument = PdfDocument.FromFile(FilePath.Text)
FileContent.Text = PDF.ExtractAllText()
End Sub
The variable PDF hosts the PDF document for processing while FileContent will store all reporting components in the PDF file using the contents from the provided data source.
Creating, manipulating, editing, and formatting PDF files using a .NET Library is a difficult task. Using TX Text Control allows you to build PDF documents programmatically. TX Text Control manages page widths, pagination, borders, titles, and paragraph breaks automatically. To generate pixel-perfect PDF documents, all these elements can be customized.
TX Text Control offers numerous ways of importing PDF files and may be transformed into editable formats such as MS Word. These papers can be edited and saved in various formats.
TX Text Control allows you to build PDFs with fillable form component menus. Documents with form components can be produced in the same way as mail merge templates. These are dynamically pre-filled with known data and allow you to create custom forms, speeding up the process of PDF manipulation.
TX Text Control is one of the market-leading .NET libraries for documentation — its main functionalities are as follows.
Merge data into MS Word compatible templates to create Adobe PDF and PDF/A. Create perfect PDF documents using floating text word processing features.
TX Text Control gives you a complete set of tools for creating documents that include fillable form components such as form text boxes, check box fields, and drop-down menus.
By embedding files in Adobe PDF documents, you may create electronic document containers. Create, import, and process documents such as invoices and attachments.
TX Text Control may utilize X.509 certificates to generate digital Adobe PDF and PDF/A documents. PFX, DER, CER, and Base64 CER certificate files can be used to construct these signatures.
Generating PDF files is often a difficult process in business applications. There are several ways to produce PDF documents in VB.NET or C#. PDF printer drivers or PDF libraries position elements on a page, but in most cases, you still have to take care of paging and more complex tasks such as widow and orphan control.
You can produce files from scratch with a fully functional API or utilize compatible, pre-designed MS Word templates with TX Text Control. Page sizes, margins, headers & footers, section breaks, and paging are taken care of by TX Text Control. These features can be controlled and stored in pixel-perfect formats such as Adobe PDF, PDF/A, DOC, DOCX, and RTF.
SaveSettings saveSettings = new SaveSettings()
{
MasterPassword = "Master",
UserPassword = "User",
DocumentAccessPermissions =
DocumentAccessPermissions.AllowLowLevelPrinting |
DocumentAccessPermissions.AllowExtractContents
};
textControl1.Save(StreamType.AdobePDF, saveSettings);
SaveSettings saveSettings = new SaveSettings()
{
MasterPassword = "Master",
UserPassword = "User",
DocumentAccessPermissions =
DocumentAccessPermissions.AllowLowLevelPrinting |
DocumentAccessPermissions.AllowExtractContents
};
textControl1.Save(StreamType.AdobePDF, saveSettings);
Dim saveSettings As New SaveSettings() With {
.MasterPassword = "Master",
.UserPassword = "User",
.DocumentAccessPermissions = DocumentAccessPermissions.AllowLowLevelPrinting Or DocumentAccessPermissions.AllowExtractContents
}
textControl1.Save(StreamType.AdobePDF, saveSettings)
TX Text Control hosts the functionality to produce Adobe PDF documents with digital signatures. These signatures can be formatted with DER, PFX, or Base64 CER certificate files. A valid certificate that is defined in the TXTextControl.SaveSettings class is required.
// Defining certificates
TXTextControl.SaveSettings settings = new TXTextControl.SaveSettings();
X509Certificate2 cert = new X509Certificate2("test.pfx", "123");
settings.DigitalSignature = new TXTextControl.DigitalSignature(cert, null);
textControl1.Save("results.pdf", TXTextControl.StreamType.AdobePDF, settings);
// Defining certificates
TXTextControl.SaveSettings settings = new TXTextControl.SaveSettings();
X509Certificate2 cert = new X509Certificate2("test.pfx", "123");
settings.DigitalSignature = new TXTextControl.DigitalSignature(cert, null);
textControl1.Save("results.pdf", TXTextControl.StreamType.AdobePDF, settings);
' Defining certificates
Dim settings As New TXTextControl.SaveSettings()
Dim cert As New X509Certificate2("test.pfx", "123")
settings.DigitalSignature = New TXTextControl.DigitalSignature(cert, Nothing)
textControl1.Save("results.pdf", TXTextControl.StreamType.AdobePDF, settings)
TX Text Control can import "digitally born" PDF files that you can view, edit or convert. One main advantage of TX Text Control is that it is fully programmable meaning you can import and modify the PDF document in any format such as DOC or DOCX. The fully-featured API can be used to change the content or to search the document. This approach can open PDF documents and enable you to search for strings in document pages.
Interactive forms in the Adobe PDF format are also known as AcroForm — the de-facto standard for PDF form processing. Internally, the form structure of a PDF document can be imported using the Adobe PDF import functionality of TX Text Control. Utilizing an extension in the DocumentServer namespace can aid in processing the output of a PDF import.
The provided code loops through all elements in listAcroForms to read the options of contained combo boxes:
AcroForm [] listAcroForms = TXTextControl.DocumentServer.Forms.PDF.ImportForms("form.pdf");
foreach (AcroForm formElement in listAcroForms)
{
if(formElement.GetType() == typeof(AcroFormComboBox))
{
string [] saOptions = ((AcroFormComboBox)formElement).Options;
}
}
AcroForm [] listAcroForms = TXTextControl.DocumentServer.Forms.PDF.ImportForms("form.pdf");
foreach (AcroForm formElement in listAcroForms)
{
if(formElement.GetType() == typeof(AcroFormComboBox))
{
string [] saOptions = ((AcroFormComboBox)formElement).Options;
}
}
Dim listAcroForms() As AcroForm = TXTextControl.DocumentServer.Forms.PDF.ImportForms("form.pdf")
For Each formElement As AcroForm In listAcroForms
If formElement.GetType() Is GetType(AcroFormComboBox) Then
Dim saOptions() As String = CType(formElement, AcroFormComboBox).Options
End If
Next formElement
The 30-day Money-Back Guarantee: when the license is purchased, you will be backed by the 30-day money-back guarantee.
Easy Integration: Integration of IronPDF with various projects and environments is incredibly easy that it can be achieved in a single line of code when NuGet or integrating into your environment by directly downloading from the web.
Perpetual Licensing: Every license purchased once will never require renewal.
Free Support and Product Updates: Each license accompanies a year of free support and product updates directly from the team behind the product. Extensions are available for purchase at any moment.
Immediate Licenses: Once payment is received, registered license keys are sent.
All purchased licenses are perpetual and apply to development, staging, and production.
The Lite Package can only be utilized by a single software developer in an organization. Iron Software can be used in intranet applications, desktop software programs, or single web applications.
Licenses are non-transferable. This means sharing outside of an organization or an agency/client relationship is not permitted. This license type along with all other licenses excludes all rights not expressly granted under the Agreement. Purchasing additional coverage is required for OEM redistribution and utilizing the Iron Software as a SaaS.
Pricing: Starts from $749 per year.
This license allows a maximum number of ten software developers in an organization to utilize Iron Software in a single location. Iron Software can be used in as many websites, intranet applications, or desktop software applications as you desire. Licenses are non-transferable, and they cannot be shared outside of an organization or an agency/client relationship. This license type, like all other license types, expressly excludes all rights not granted under the Agreement, including OEM redistribution and utilizing the Iron Software as a SaaS without purchasing additional coverage. This license can be integrated with a single project and up to a maximum of 10.
Pricing: Starts from $999 per year.
This license enables an unlimited number of software developers in an organization to utilize Iron Software in an unlimited number of locations. The Iron Software can be used in as many websites, intranet applications, or desktop software applications as you like. Licenses are non-transferable, and they cannot be shared outside of an organization or an agency/client relationship. This license type, like all other license types, expressly excludes all rights not granted under the Agreement, including OEM redistribution and utilizing the Iron Software as a SaaS without purchasing additional coverage.
Pricing: Starts from $2999 per year.
Royalty-Free Redistribution: This enables you to distribute Iron Software as part of several different packaged commercial products (without having to pay royalties) depending on the number of projects covered by the base license. It allows for the deployment of Iron Software within SaaS software services, based on the number of projects covered by the base license.
Pricing: Starts from $1599 per year.
Licensing Policy: Each developer using these products must have their own assigned license. All licenses are perpetual.
Maintenance and Support: Subscriptions include one-year access to updates and service packs, as well as an unlimited number of support incidents through e-mail, telephone, and chat.
Subscription Renewals: One-year renewal of a TextControl subscription is 40% of the listed price.
TX Text Control .NET for Windows Forms Enterprise 30.0:
Pricing: Starts from $3398.00 per year.
TX Text Control .NET for Windows Forms Enterprise 30.0:
Pricing: Starts from $6749.00 per year
TX Text Control .NET for Windows Forms Professional 30.0:
Pricing: Starts from $3249.00 per year.
The IronPDF Lite package including one developer package with one year of support costs around about $749. With Text Control, a one-developer package costs $3399, including all updates, major releases, and technical support for 12 months. The IronPDF professional package for 10 developers with one year of support costs $999. Text Control does not have a 10-developer package — exclusively only having 4-developer packages that cost $6749.00 per year, including all updates, major releases, and technical support for 12 months.
Both the IronPDF lite and professional packages include SaaS service or OEM, as well as a 5-year support option. The Lite package for one developer with 5-year support and SaaS and OEM service costs $2897. The Iron Professional 10-developer package with 5-year support and SaaS and OEM service costs $3397. Text Control does not have a SaaS service or OEM, nor a 5-year support option.
The IronPDF Library comes with many functionalities. Using IronPDF's HTML-to-PDF method, you can render razor view to string, use it as a PDF reader in C# and help visualize and export SSRS reports to PDF in ASP.NET applications. Additionally, IronPDF can be used to render snapshots of data as "reports" in PDF format.
IronPDF also works as a PDF C# parser. The basic approach is to first generate a report as an HTML document and then render the HTML as a PDF using IronPDF.
Styling an XML report requires the XML to be parsed to generate an HTML with the data. These reports may be generated as HTML and can then be customized and converted to PDF documents using IronPDF. The simplest 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.
There are several ways to import PDF documents using Text Control. Documents can be imported and converted into other formats such as MS Word and can be modified and saved in other editable formats. There is a full-text search function for PDF documents that allows you to retrieve the positions and coordinates of elements. Additionally, the ability to perform an extraction for results retrieved from forms is possible using Text Control's function, extract form field values. Radial search is also a function that will allow you to return lines from a specific provided radius and location.
IronPDF has been shown to perform very accurately when converting documents. Competitors alike have shown to inaccurately produce results such as failed conversions of images resulting in unknown characters. On the other hand, IronPDF provides very accurate results.
IronPDF packages have competitive licensing and support, have no ongoing costs, and are more budget-friendly than some competing brands. Text Control packages start at $1649 per year. IronPDF starts at $749 and supports multiple platforms for a single price while accommodating an impressive variety of features.
If you are not yet an IronPDF customer, the free trial allows you to check out all the available features. If you buy the complete Iron Suite, you can get all five products for the price of just two! For further details about Iron Software Licensing, please visit the Iron Suite Purchase Guide to purchase the complete package.
9 .NET API products for your office documents