USING IRONPDF

PDF Library for .NET Converter

Jordi Bardia
Jordi Bardia
October 19, 2021
Updated December 3, 2023
Share:

Making a PDF in a C# .NET Library is easy and efficient with the right guides. Using IronPDF, we're able to create and edit PDF features in a simple manner according to our application requirements. This tutorial example shows how to use the software efficiently in your project and create a PDF with just one button click!


Step 1

1. Install the C# PDF Library .NET

The two main ways of accessing the library are either:

  1. Download and unpack the [IronPDF Package](https://ironpdf.com/packages/IronPdf.Package.For.PDF.NET.Library.zip) DLL file
  2. Navigate to [NuGet](https://www.nuget.org/packages/IronPdf) and install the package via Visual Studio.


Install-Package IronPdf

How to Tutorial

2. Use the PDF .NET Library

PDF Library for .NET Converter, Figure 1: C# Icon
PDF Library for .NET Converter, Figure 2: Converter Icon
PDF Library for .NET Converter, Figure 3: pen and ruler Icon
PDF Library for .NET Converter, Figure 2: Converter Icon
PDF Library for .NET Converter, Figure 4: Adobe Icon

Now that we have the software, we can generate PDFs, adjust settings, add custom text and images, and manipulate the PDFs to our project requirements.

In the below code, we have used a C# Form demonstrating simply how to create a PDF with the C# .NET library. In this example, we have a TextBox to write our own text and then just click on a button to make a PDF. The class ChromePdfRenderer offers the simplest possible way to generate PDF files from different sources including an HTML string, web URLs, or doc files under another renderer.

/**
PDF NET Generator
anchor-use-the-pdf-net-library
**/
using IronPdf;
using System.Windows.Forms;

namespace readpdf
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
            //Used ChromePdfRenderer Convert Class
            var HtmlLine = new ChromePdfRenderer();

            //Getting Text from TextBox
            string text = textBox1.Text;

            //Here we are rendering or converting htmlaspdf.
            using var pdf = HtmlLine.RenderHtmlAsPdf("<h1>"+text+"</h1>");
      pdf.SaveAs("custom.pdf");

            //Confirmation
            MessageBox.Show("Done !");
        }
    }
}
/**
PDF NET Generator
anchor-use-the-pdf-net-library
**/
using IronPdf;
using System.Windows.Forms;

namespace readpdf
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
            //Used ChromePdfRenderer Convert Class
            var HtmlLine = new ChromePdfRenderer();

            //Getting Text from TextBox
            string text = textBox1.Text;

            //Here we are rendering or converting htmlaspdf.
            using var pdf = HtmlLine.RenderHtmlAsPdf("<h1>"+text+"</h1>");
      pdf.SaveAs("custom.pdf");

            //Confirmation
            MessageBox.Show("Done !");
        }
    }
}

3. C# Form to PDF

We have used a C# Windows Forms App to show you the perfect output with custom text. In just a single click, the text in the TextBox gets converted to a custom PDF. This requires only a single-line code function and is easy to understand.

~ C# Form ~

PDF Library for .NET Converter, Figure 4: Windows Forms App to custom PDF file

~ PDF ~

PDF Library for .NET Converter, Figure 5: Pdf File output

Library Quick Access

Documentation related to Library Quick Access

Share API Reference

Read through and share the API Reference for all the functionality you need to work with PDFs in your .NET project.

API Reference for IronPDF
Jordi Bardia
Software Engineer
Jordi is most proficient in Python, C# and C++, when he isn’t leveraging his skills at Iron Software; he’s game programming. Sharing responsibilities for product testing, product development and research, Jordi adds immense value to continual product improvement. The varied experience keeps him challenged and engaged, and he says it’s one of his favorite aspects of working with Iron Software. Jordi grew up in Miami, Florida and studied Computer Science and Statistics at University of Florida.
< PREVIOUS
5 steps to Generate a PDF File in C# using IRON PDF
NEXT >
.NET PDF Generator in 1 Click