Deploying a Python application that generates or manipulates PDFs requires a valid IronPDF license key. Without one, every output document carries an IronPDF watermark and the library operates in trial mode. Applying your key takes fewer than five lines of code and must happen before any PDF operation runs.

Quickstart: Apply an IronPDF License Key in Python

How Do You Install IronPDF for Python?

Before applying a license key, IronPDF must be present in the Python environment. Install it using pip:

//:path=install.sh
:ProductInstall
//:path=install.sh
:ProductInstall
SHELL

Please noteIronPDF for Python is built on the IronPDF .NET library and requires the .NET 6.0 SDK to be installed on the host machine. Download it from Microsoft before running pip install.

Once pip completes, the ironpdf package is available for import in any script within the active environment. No additional configuration is needed beyond the .NET runtime dependency.

How Do You Apply an IronPDF License Key in Python?

Set the LicenseKey attribute on the License class at the very beginning of your script — before calling any IronPDF API. Placing the key assignment after PDF operations will have no effect on those calls.

//:path=apply_license.py
from ironpdf import License

# Apply your license key before any PDF operation
License.LicenseKey = "IRONPDF-MYLICENSE-KEY-1EF01"
//:path=apply_license.py
from ironpdf import License

# Apply your license key before any PDF operation
License.LicenseKey = "IRONPDF-MYLICENSE-KEY-1EF01"
PYTHON

TipsThe license key must be assigned before the first IronPDF operation in every script entry point. If your project has multiple entry points — such as a web handler and a background worker — add the assignment to each one.

A free 30-day trial key is available if you want to evaluate the full feature set before purchasing. Trial keys follow the same assignment syntax. To acquire a full license, visit the IronPDF Python licensing page.

How Do You Verify and Validate an IronPDF License Key?

Two members of the License class serve different verification purposes: IsLicensed checks whether a valid key is currently active in the runtime, while IsValidLicense() checks whether a specific key string is structurally valid and recognized by IronPDF's licensing server.

Checking Whether the Runtime Is Licensed

License.IsLicensed is a boolean attribute that returns True when a valid license key has been applied in the current runtime session. It returns False when operating in trial mode (no key, expired key, or a key applied after PDF operations have already run).

//:path=check_is_licensed.py
from ironpdf import License

# Apply license before checking
License.LicenseKey = "IRONPDF-MYLICENSE-KEY-1EF01"

# Returns True if a valid key is active in this session
is_licensed = License.IsLicensed
print(f"Runtime is licensed: {is_licensed}")
//:path=check_is_licensed.py
from ironpdf import License

# Apply license before checking
License.LicenseKey = "IRONPDF-MYLICENSE-KEY-1EF01"

# Returns True if a valid key is active in this session
is_licensed = License.IsLicensed
print(f"Runtime is licensed: {is_licensed}")
PYTHON

Use IsLicensed in application startup logic or health checks to confirm the runtime state.

Validating a Specific Key String

License.IsValidLicense(key) accepts a key string and returns True if that specific key is valid and activated, or False if it is malformed, expired, or not recognized. This is useful when accepting license keys from configuration files or environment variables.

//:path=validate_license_key.py
from ironpdf import License

# Validate a key string before applying it
key_to_check = "IRONPDF-MYLICENSE-KEY-1EF01"
is_valid = License.IsValidLicense(key_to_check)

if is_valid:
    License.LicenseKey = key_to_check
    print("License key is valid and has been applied.")
else:
    print("License key is invalid. Check the key and try again.")
//:path=validate_license_key.py
from ironpdf import License

# Validate a key string before applying it
key_to_check = "IRONPDF-MYLICENSE-KEY-1EF01"
is_valid = License.IsValidLicense(key_to_check)

if is_valid:
    License.LicenseKey = key_to_check
    print("License key is valid and has been applied.")
else:
    print("License key is invalid. Check the key and try again.")
PYTHON

ImportantThe key difference: IsLicensed reflects the current runtime state regardless of which key was applied. IsValidLicense() evaluates a specific key string. Use IsValidLicense() to validate input from external sources before applying the key.

What Happens After Applying a License in a Deployed Application?

For development and local testing, the license key takes effect immediately in the running process. No rebuild or republish is required. For production deployments and live applications, the recommended practice is to clean and republish the application after updating the license key to prevent stale environment state from causing unexpected behavior.

Store the license key in an environment variable or a secrets manager rather than hardcoding it in source code. Read the key at application startup and assign it before the first PDF operation:

//:path=license_from_env.py
import os
from ironpdf import License

# Read the license key from an environment variable
license_key = os.environ.get("IRONPDF_LICENSE_KEY", "")

if license_key:
    License.LicenseKey = license_key
else:
    print("Warning: IRONPDF_LICENSE_KEY is not set. Running in trial mode.")
//:path=license_from_env.py
import os
from ironpdf import License

# Read the license key from an environment variable
license_key = os.environ.get("IRONPDF_LICENSE_KEY", "")

if license_key:
    License.LicenseKey = license_key
else:
    print("Warning: IRONPDF_LICENSE_KEY is not set. Running in trial mode.")
PYTHON

This pattern keeps sensitive credentials out of version control and works across development, staging, and production environments without code changes.

Please noteIronPDF generates a watermark on every PDF page when operating in trial mode. To remove the watermark from all output, a valid license key must be applied before any rendering or manipulation operation.

What Are the Next Steps?

With a valid license key applied, IronPDF for Python is ready for full production use. Consider these resources to move forward:

Frequently Asked Questions

Where do I place the IronPDF license key assignment in a Python script?

Assign the key using License.LicenseKey = 'YOUR-KEY' at the very top of your script, before any other IronPDF calls. Applying the key after a PDF operation has already run will not remove the watermark from that operation.

What is the difference between IsLicensed and IsValidLicense() in IronPDF for Python?

License.IsLicensed is a boolean attribute that reflects whether a valid key is active in the current runtime session. License.IsValidLicense(key) is a method that checks whether a specific key string is valid and recognized — useful for validating keys read from environment variables or config files before applying them.

How do I get a free trial license key for IronPDF in Python?

Visit the IronPDF trial license page and register for a free 30-day trial key. Apply it the same way as a full license key using License.LicenseKey = 'YOUR-TRIAL-KEY'.

Does IronPDF for Python require the .NET SDK to be installed?

Yes. IronPDF for Python is built on the IronPDF .NET library and requires the .NET 6.0 SDK to be installed on the host machine. Download it from the Microsoft .NET download page before running pip install ironpdf.

What happens if I use IronPDF without a license key?

Without a valid license key, IronPDF operates in trial mode and stamps a watermark on every page of every generated or processed PDF document. To remove the watermark, apply a valid full or trial license key before the first PDF operation.

How should I store an IronPDF license key securely in a production application?

Store the license key in an environment variable such as IRONPDF_LICENSE_KEY and read it at application startup using os.environ.get. Assign it to License.LicenseKey before any PDF operations run. This keeps the key out of source control.

Do I need to restart or republish the application after applying a new license key?

During development, the key takes effect immediately in the running process. For production deployments, clean and republish the application after updating the license key to prevent stale environment state.

Can I apply an IronPDF license key once and reuse it across multiple scripts?

The License.LicenseKey assignment applies to the current process only. Each script or process entry point must assign the key before calling IronPDF APIs. If your project has multiple entry points, add the assignment to each one.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More
Ready to Get Started?
Version: 2026.5 just released
Still Scrolling Icon

Still Scrolling?

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