Skip to footer content
USING IRONPDF

PDF Library for .NET Converter

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.


# Use the NuGet package manager to install IronPDF
nuget install IronPdf
# Use the NuGet package manager to install IronPDF
nuget install IronPdf
SHELL

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.

// C# Program to create PDF from TextBox input using IronPDF
using IronPdf;
using System.Windows.Forms;

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

        // Event handler for the button click
        private void button1_Click(object sender, System.EventArgs e)
        {
            // Create a ChromePdfRenderer object to convert HTML to PDF
            var HtmlLine = new ChromePdfRenderer();

            // Retrieve the text from the TextBox
            string text = textBox1.Text;

            // Render the HTML as a PDF, wrapping the text in an <h1> tag
            using var pdf = HtmlLine.RenderHtmlAsPdf("<h1>" + text + "</h1>");

            // Save the PDF to a file called "custom.pdf"
            pdf.SaveAs("custom.pdf");

            // Show a confirmation message to the user
            MessageBox.Show("Done!");
        }
    }
}
// C# Program to create PDF from TextBox input using IronPDF
using IronPdf;
using System.Windows.Forms;

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

        // Event handler for the button click
        private void button1_Click(object sender, System.EventArgs e)
        {
            // Create a ChromePdfRenderer object to convert HTML to PDF
            var HtmlLine = new ChromePdfRenderer();

            // Retrieve the text from the TextBox
            string text = textBox1.Text;

            // Render the HTML as a PDF, wrapping the text in an <h1> tag
            using var pdf = HtmlLine.RenderHtmlAsPdf("<h1>" + text + "</h1>");

            // Save the PDF to a file called "custom.pdf"
            pdf.SaveAs("custom.pdf");

            // Show a confirmation message to the user
            MessageBox.Show("Done!");
        }
    }
}
' C# Program to create PDF from TextBox input using IronPDF
Imports IronPdf
Imports System.Windows.Forms

Namespace readpdf
	Partial Public Class Form1
		Inherits Form

		Public Sub New()
			InitializeComponent()
		End Sub

		' Event handler for the button click
		Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
			' Create a ChromePdfRenderer object to convert HTML to PDF
			Dim HtmlLine = New ChromePdfRenderer()

			' Retrieve the text from the TextBox
'INSTANT VB NOTE: The variable text was renamed since Visual Basic does not handle local variables named the same as class members well:
			Dim text_Conflict As String = textBox1.Text

			' Render the HTML as a PDF, wrapping the text in an <h1> tag
			Dim pdf = HtmlLine.RenderHtmlAsPdf("<h1>" & text_Conflict & "</h1>")

			' Save the PDF to a file called "custom.pdf"
			pdf.SaveAs("custom.pdf")

			' Show a confirmation message to the user
			MessageBox.Show("Done!")
		End Sub
	End Class
End Namespace
$vbLabelText   $csharpLabel

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

Frequently Asked Questions

What is a PDF library for .NET?

IronPDF is a PDF library for .NET that allows developers to easily create and edit PDFs within C# projects.

How can I install a PDF library in my C# project?

You can install IronPDF by downloading the IronPDF package DLL file or by using NuGet to install the package via Visual Studio.

How do I create a PDF from C# using a PDF library?

Using IronPDF, you can create a PDF by writing a simple function in C#. This involves using the ChromePdfRenderer object to convert HTML to PDF.

Can I convert a C# form to a PDF using a PDF library?

Yes, you can convert a C# form to a PDF using IronPDF by implementing a function to capture the form data and render it as a PDF.

What is the simplest method to generate PDFs with a PDF library?

The simplest method to generate PDFs with IronPDF is using the ChromePdfRenderer object to render an HTML string or URL directly into a PDF.

How do I add custom text and images to a PDF using a PDF library?

You can add custom text and images to a PDF by manipulating the HTML content before rendering it to PDF using IronPDF.

Is it possible to edit existing PDFs with a PDF library?

Yes, IronPDF provides functionality to manipulate and edit existing PDFs to meet your project requirements.

Where can I find the API reference for a PDF library?

You can access the API reference for IronPDF on their official website at ironpdf.com, under the API Reference section.

What are the main features of a PDF library?

IronPDF allows for PDF creation, editing, conversion from HTML, adding custom text and images, and much more, making it a versatile tool for .NET developers.

Can I convert a URL directly into a PDF using a PDF library?

Yes, IronPDF supports converting a web URL directly into a PDF using the ChromePdfRenderer object.

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.
Talk to an Expert Five Star Trust Score Rating

Ready to Get Started?

Nuget Passed