Apply an Aspose.HTML License in Python

Aspose.HTML for Python via .NET can be evaluated without a license, licensed with a purchased or temporary license file, or used with metered licensing. Apply the license before creating or processing documents so that the selected licensing mode covers the complete workflow.

For standard licensing, create an aspose.html.License object and call set_license() with the license file path or stream. For usage-based licensing, create an aspose.html.Metered object and apply the public and private metered keys.

Evaluate Aspose.HTML for Python via .NET

The package can be installed and used without a license for evaluation. Evaluation mode provides access to the API but applies output limitations, such as evaluation watermarks and processing limits.

To test the library without evaluation limitations, request a free 30-day temporary license. A temporary license uses the same License.set_license() workflow as a purchased license file.

Apply a License File or Stream

Store the license file in a location that your application can read and pass its path to License.set_license().

The following example applies a license from a file:

1import aspose.html as ah
2
3license = ah.License()
4license.set_license("license/Aspose.HTML.Python.via.NET.lic")

You can provide either a full path or a path relative to the application’s working directory. The method also accepts a binary stream containing the license. Apply the license once during application startup, before loading or converting documents.

If an application uses several Aspose products, use the fully qualified class name, such as aspose.html.License, to ensure that the license is applied to the intended product.

Apply a Metered License

Metered licensing uses public and private keys instead of a license file and records API usage for billing. Obtain the keys through your Aspose account and pass them to Metered.set_metered_key():

1import aspose.html as ah
2
3public_key = "your-public-key"
4private_key = "your-private-key"
5
6metered = ah.Metered()
7metered.set_metered_key(public_key, private_key)

Apply the metered keys when the application starts. Metered licensing must be able to send usage information for billing. If this information cannot be sent for more than 24 hours, the product can switch to evaluation mode. Use Metered.is_metered_licensed() to check the status and apply the keys again after connectivity is restored if necessary. See the Metered Licensing FAQ for account and billing details.

Common Licensing Issues

IssueLikely CauseRecommended Action
Evaluation watermark remainsThe license was not found, was applied after document processing started, or belongs to another Aspose product.Check the path and product name, then apply the license before creating or converting documents.
License file cannot be foundA relative path is resolved from a different working directory.Use a verified absolute path or place the file in an application-controlled location.
The wrong Aspose product is licensedThe application imports several classes named License.Instantiate aspose.html.License explicitly.
Metered licensing switches to evaluation modeConsumption data could not be uploaded for more than 24 hours.Restore connectivity, check the metered status, and apply the keys again if required.

Next Steps