IRONSOFTWAREHOME
Set Temp PDF File Path
from ironpdf import *
import os

# Set application scope temp path
my_temp_path = "C:/safe/location/"
os.environ["TEMP"] = my_temp_path
os.environ["TMP"] = my_temp_path

# Set IronPDF temp path
Installation.TempFolderPath = os.path.join(my_temp_path, "IronPdfTemp")

string = os.path.join(my_temp_path, "IronPdfTemp")

# Your PDF generation and editing code here
renderer = ChromePdfRenderer()
doc = renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>")
doc.SaveAs("example.pdf")
pip install ironpdf
Set Temp PDF File Path

Set Temp PDF File Path

IronPDF uses temporary files during PDF rendering. By default these are written to the system temp directory. This example shows how to redirect both the system temp path and IronPDF's own temp folder to a location of your choice.

Getting Started

Set the TEMP and TMP environment variables through Python's os.environ before any rendering occurs. Then assign a subdirectory within that path to Installation.TempFolderPath so IronPDF writes its own working files to the same controlled location.

Understanding the Code

  • os.environ["TEMP"] / os.environ["TMP"]: Override the operating-system temp directory for the current process.
  • Installation.TempFolderPath: Directs IronPDF to use a specific folder for its internal temporary files. Set this before the first render call.
  • os.path.join: Constructs a platform-safe path by combining the base temp directory with an IronPdfTemp subfolder.

When to Use a Custom Temp Path

Redirecting the temp path is useful in:

  • Containerized or sandboxed environments where the default system temp folder is restricted.
  • High-security deployments where all file I/O must occur within an audited directory.
  • Shared hosting scenarios where you need to isolate one application's temp files from another's.

After setting the paths, use ChromePdfRenderer as normal - no other code changes are required.

Ready to Get Started?

Version: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
Python Module Download for PDF
Install with pip

Version: 2026.9

  1. Download and install Python 3.7+.
  2. Install pip from pypi.org if it isn't installed already.
  3. Execute the above command in the terminal.
Python PDF Module
Download Module

Version: 2026.9

Manually install into your project

  1. Download the package
  2. Run this command from the terminal
    pip install ironpdf-2026.9-py37-none-win_amd64.whi

Licenses from $999