How to Install the IronPDF Library to a .NET Project
Installing the C# PDF library takes less than 5 minutes.
The free for development software is available via NuGet and direct download, and with this tutorial we'll get you up and running in Visual Studio. Follow the instructions below to start converting HTML to PDF in your .NET project.
Step-by-Step C# PDF Library Installation
How to Tutorial
1.1. Install IronPDF via NuGet
Use the next few steps to install the IronPDF NuGet library from within Visual Studio.
- In Solution Explorer, right-click References, Manage NuGet Packages
- Select Browse and search
"IronPdf"
- Select the package and install.
Install-Package IronPdf
There are also IronPDF NuGet Packages available for specific deployments to Mac, Linux, Azure, Docker and AWS documeted in our IronPDF advanced NuGet installation guide.
1.2. Install IronPDF by DLL Download
The second way to install IronPDF is by downloading it. Follow these quick and easy steps:
- Download and unzip the Windows IronPDF file to a location such as ~/Libs within your Solution directory
- In Visual Studio Solution Explorer, right click on 'Dependencies' and 'Add Project Reference'. Select Browse and include all the dll extracted from the zip.
Here are other IronPDF DLL zip packages available for specific platforms:
Apply License Key
Include this code at the startup of your application, before using IronPDF. This approach is universally effective and easy to implement.
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"
If you prefer not to apply the license key using inline code, please visit the 'IronPDF License Keys' article to explore alternative methods.
2. Grant Necessary Access to File or Folder
It may sometimes be necessary to add permissions to certain users or roles on your PC.
For instance, each AppDomain requires its own TempFolderPath and Applications in the same AppPool cannot share a TempFolderPath.
Now what does this mean?
An AppDomain simply provides a layer of isolation within a certain process. Everything you think of as per-program is in reality per-AppDomain. Each of these applications in the same application pool requires its own Temporary folder in order to function fully independently.
If necessary for any of the abovementioned troubleshooting options, you can set permissions in the following way:
- Right click on a file or folder
- Select Properties
- Select Security
- Click Edit…
- Select the desired permissions.
3. Set Installation Path
To render HTML as a PDF, IronPDF must embed Chromium, which is a safe web browser. Luckily, this process is entirely automated.
If IronPDF's HTML to PDF throws a "failed rendering" exception, which is very unlikely, you may have to unpack the native browser binaries to an appropriate location. The Temp folder is normally ideal.
Note: Program Files is never an appropriate location.
Setting IronPdf.Installation.TempFolderPath
You can unpack to the right location by setting the TempFolderPath property of the IronPdf.Installation object as shown here:
IronPdf.Installation.TempFolderPath = @"C:\My\Safe\Path";
After updating a path always remember to clear all temp and cache folders on your development and servers. Redeploy a CLEAN version of your application.
Setting The Temp Folder Environment Variable at Application Scope
IronPDF may occasionally generate Temporary files while rendering and editing PDF documents into a System temp folder. We can set IronPdf.Installation.TempFolderPath to work around this also, yet the Environmental TempPath Directory may still sometimes be used by 3rd party packages.
To resolve this issue we can set the TempPath Environmental Variable application wide in C# application startup. This ensures all temporary files created by your application are stored in a controllable location.
using IronPdf;
// Set Application scope Temp Files Path.
// This changes System.IO.Path.GetTempFileName and System.IO.Path.GetTempPath behavior for the entire .NET application
var MyTempPath = @"C:\Safe\Path\";
Environment.SetEnvironmentVariable("TEMP", MyTempPath, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("TMP", MyTempPath, EnvironmentVariableTarget.Process);
// Set IronPDF Temp Path
IronPdf.Installation.TempFolderPath = System.IO.Path.Combine(MyTempPath, "IronPdf");
// Your PDF Generation and editing code here..E.G.
var Renderer = new IronPdf.ChromePdfRenderer();
using var Doc = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");
Doc.SaveAs("example.pdf");
using IronPdf;
// Set Application scope Temp Files Path.
// This changes System.IO.Path.GetTempFileName and System.IO.Path.GetTempPath behavior for the entire .NET application
var MyTempPath = @"C:\Safe\Path\";
Environment.SetEnvironmentVariable("TEMP", MyTempPath, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("TMP", MyTempPath, EnvironmentVariableTarget.Process);
// Set IronPDF Temp Path
IronPdf.Installation.TempFolderPath = System.IO.Path.Combine(MyTempPath, "IronPdf");
// Your PDF Generation and editing code here..E.G.
var Renderer = new IronPdf.ChromePdfRenderer();
using var Doc = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");
Doc.SaveAs("example.pdf");
Imports IronPdf
' Set Application scope Temp Files Path.
' This changes System.IO.Path.GetTempFileName and System.IO.Path.GetTempPath behavior for the entire .NET application
Private MyTempPath = "C:\Safe\Path\"
Environment.SetEnvironmentVariable("TEMP", MyTempPath, EnvironmentVariableTarget.Process)
Environment.SetEnvironmentVariable("TMP", MyTempPath, EnvironmentVariableTarget.Process)
' Set IronPDF Temp Path
IronPdf.Installation.TempFolderPath = System.IO.Path.Combine(MyTempPath, "IronPdf")
' Your PDF Generation and editing code here..E.G.
Dim Renderer = New IronPdf.ChromePdfRenderer()
Dim Doc = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>")
Doc.SaveAs("example.pdf")
4. Permissions and IIS
In the event that the server has been locked down, you may need to give the IIS user (IUSER) read and write permissions to your Installation Path Folder, as well as to your Windows and Temp Folder.
5. Microsoft Visual C++ and Windows Compatibility
IronPDF needs Microsoft Visual C++ to be installed on the target windows machine. It can be packed with an application installer such as an MSI if necessary.
Microsoft Visual C++ is a windows component and is normally present on modern versions of windows unless they have been deliberately stripped down.
The .NET Framework can run as 32-bit (even on 64-bit platforms), so it is necessary to install Visual C++ in both 32 and 64-bit versions.
Here you can download Microsoft Visual C++.
6. Linux Compatibility
- IronPDF supports Linux. We officially support: Ubuntu, Debian, CentOS, Fedora & Amazon Linux 2.
- Deploying IronPDF on Linux is well documented and a popular choice for cloud deployments such as Azure.
7. Docker Compatibility
- Deploying IronPDF on Docker is well documented.
- We officially support Docker for: Windows, Ubuntu, Debian, CentOS & Amazon Linux 2 and provide working Docker files.
8. Azure Compatibility
- Official Support for Azure WebApps, Azure WebJobs, Azure Functions and Azure Docker instances and Azure VMs.
- Read the IronPDF Azure & Azure Function Setup Guide.
9. Amazon AWS Lambda Compatibility
- A tutorial and support for Amazon AWS Lambda is included.
10. macOS Compatibility
- Official Support for macOS deployments and development using Rider and "Visual Studio for Mac" are supported
- Please read our comprehensive macOS guide.