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.6 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast?
run a sample watch your HTML become a PDF.