How to Install and Deploy the IronPDF C# Library

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.


How to Tutorial

1.1. Install IronPDF via NuGet

Use the next few steps to install the IronPDF NuGet library from within Visual Studio.

  1. In Solution Explorer, right-click References, Manage NuGet Packages

  2. Select Browse and search "IronPdf"

  3. Select the package and install.
PM > Install-Package IronPdf


1.2. Install IronPDF by Direct Download

The second way to install IronPDF is by downloading it. Follow these quick and easy steps:

  1. Download and unzip the IronPDF file to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"


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:

  1. Right click on a file or folder

  2. Select Properties

  3. Select Security

  4. Click Edit…

  5. 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 issuewe 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 controlable 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 = Path.Combine(MyTempPath,"IronPdf");

// Your PDF Generation and editing code here..E.G.
var Renderer = new IronPdf.HtmlToPdf();
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 = Path.Combine(MyTempPath,"IronPdf");

// Your PDF Generation and editing code here..E.G.
var Renderer = new IronPdf.HtmlToPdf();
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
'INSTANT VB TODO TASK: The following line could not be converted:
Private MyTempPath = "C:\Safe\Path\"
Environment.SetEnvironmentVariable("TEMP", MyTempPath, EnvironmentVariableTarget.Process)
Environment.SetEnvironmentVariable("TMP", MyTempPath, EnvironmentVariableTarget.Process)

' Set IronPDF Temp Path
IronPdf.Installation.TempFolderPath = Path.Combine(MyTempPath,"IronPdf")

' Your PDF Generation and editing code here..E.G.
Dim Renderer = New IronPdf.HtmlToPdf()
Dim Doc = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>")
Doc.SaveAs("example.pdf")
VB   C#


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++

IronPDF needs Microsoft Visual C++ to be installed on the target server packed with your installer. 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. Docker and Linux support

IronPDF for .NET Core supports Linux and Docker.

Docker is simply a set of Platform as a Service (PAAS) products that makes use of operating system virtualization to provide software in packages called containers.

Linux is a family of Open-Source Unix-like operating systems based on the Linux kernel.

An example of a Docker file for Linux looks like the following:

\# escape=`

FROM mcr.microsoft.com/dotnet/core/runtime:2.1

\# Mount folder for an application

VOLUME /app

WORKDIR /app

The second line determines which .NET Core runtime you'd like to support, so for .NET Core 3.1 just change the line to:

\# escape=`

FROM mcr.microsoft.com/dotnet/core/runtime:3.1

\# Mount folder for an application

VOLUME /app

WORKDIR /app

A Docker file for Windows is a bit longer and contains more information. Here is an example:

\# escape=`

FROM mcr.microsoft.com/windows/servercore:ltsc2019

\# Create folder for .NET Core installer

WORKDIR /dotnet-install

\# Download .NET Core installer

ADD https://download.visualstudio.microsoft.com/download/pr/a431ea89-07d9-4533-9d72-fd246bd2efc7/5bbc08f02800c08b69bce56d03723f18/dotnet-hosting-2.1.17-win.exe dotnet-installer.exe

\# Execute .NET Core installer

USER ContainerAdministrator

RUN dotnet-installer.exe /install /quiet /norestart /log dotnet-install.log || exit 0

\# Print installation log to the Console

USER ContainerUser

RUN type dotnet-install.log

\# Mount application folder

VOLUME c:\app

To change the supported .NET Core runtime, just edit the section under ADD as follows:

\# Download .NET Core installer-

ADD https://download.visualstudio.microsoft.com/download/pr/ff658e5a-c017-4a63-9ffe-e53865963848/15875eef1f0b8e25974846e4a4518135/dotnet-hosting-3.1.3-win.exe dotnet-installer.exe

For further deployment advice, check out the IronPDF Linux and Docker Guide.