IRONSOFTWAREHOME
Set Temp PDF File Path
using IronPdf;
using System;
using System.IO;

// Set Application scope Temp Path (On Linux /tmp is a good choice)
var MyTempPath = @"C:\Safe\Location\";

Environment.SetEnvironmentVariable("TEMP", MyTempPath);
Environment.SetEnvironmentVariable("TMP", MyTempPath);

// Set IronPDF Temp Path
Installation.TempFolderPath = Path.Combine(MyTempPath, "IronPdfTemp");

// Your PDF Generation and editing code here
var renderer = new ChromePdfRenderer();
var doc = renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");
doc.SaveAs("example.pdf");
Imports IronPdf
Imports System
Imports System.IO

' Set Application scope Temp Path (On Linux /tmp is a good choice)
Dim MyTempPath = "C:\Safe\Location\"

Environment.SetEnvironmentVariable("TEMP", MyTempPath)
Environment.SetEnvironmentVariable("TMP", MyTempPath)

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

' Your PDF Generation and editing code here
Dim renderer = New ChromePdfRenderer()
Dim doc = renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>")
doc.SaveAs("example.pdf")
NuGet Download
PM > Install-Package IronPdf
Set Temp PDF File Path

Set Temp PDF File Path

When working with IronPDF, you may find the program creating temporary files as you generate, modify, and render PDF documents. This process occurs as it would for any other software to temporarily store data while the program is running, and it may be necessary to ensure proper program functionality. With IronPDF, you will have full control over where this folder is created and other important settings related to the temporary files.

Steps to Setting Temp File Paths with IronPDF

Explanation:

  1. Define Custom Path: We start by defining MyTempPath, a string variable containing the directory path where temporary files will be stored. Ensure this directory exists or has the necessary permissions, as IronPDF will use it during its operations.
  2. Set Environment Variables
    • The Environment.SetEnvironmentVariable function is used to set the TEMP environment variable to point to our custom path MyTempPath. This is a common system-wide variable used by applications, including IronPDF, to determine where temporary files should be stored.
  3. Set IronPDF Temp Folder Path
    • Installation.TempFolderPath property is set using Path.Combine to append "IronPdfTemp" to our custom path, creating a subdirectory specifically for IronPDF's temporary files.
  4. Generate PDF
    • We instantiate a ChromePdfRenderer, which is used to convert HTML content to a PDF.
    • The method RenderHtmlAsPdf() is called on the renderer object with a sample HTML string, which generates the PDF document stored in the doc variable.
    • We save the generated PDF to a file named "example.pdf" using doc.SaveAs().

By controlling the temporary file path, you can monitor and manage the files generated during PDF creation, ensuring that your application operates smoothly without cluttering default temporary directories.

Explore Custom Logging with IronPDF for More Control
View on GitHub

Ready to Get Started?

Nuget Downloads 21,105,021Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

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

Licenses from $999