Licensing | Aspose.Page for .NET

Evaluation Version Limitations

We want our customers to test our components thoroughly before buying so the evaluation version allows you to use it as you would normally. However, the unlicensed product:

Classic license

The license can be loaded from a file or stream object. The easiest way to set a license is to put the license file in the same folder as the Aspose.Page.dll file and specify the file name, without a path, as shown in the example below.

Loading a license from file

The easiest way to apply a license is to put the license file in the same folder as the Aspose.Page.dll file and specify just the file name without a path.

If you use are using any other Aspose for .NET component along with Aspose.Page for .NET, please specify the namespace for License like Aspose.Page.License.

1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
2// The path to the documents directory.
3string dataDir = RunExamples.GetDataDir_GettingStarted();
4// Initialize license object
5License license = new License();
6// Set license
7license.SetLicense("D:\\Aspose.Total.NET.lic");
8Console.WriteLine("License set successfully.");

When you call the SetLicense method, the license name that you pass should be that of your license file. For example, if you change the license file name to “Aspose.Page.lic.xml” pass that file name to the license.SetLicense(…) method.

Loading a License from a Stream Object

The following example shows how to load a license from a stream.

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2// The path to the documents directory.
 3string dataDir = RunExamples.GetDataDir_GettingStarted();
 4// Initialize license object
 5Aspose.Page.License license = new Aspose.Page.License();
 6// Load license in FileStream
 7FileStream myStream = new FileStream("Aspose.Total.NET.lic", FileMode.Open);
 8// Set license
 9license.SetLicense(myStream);
10Console.WriteLine("License set successfully.");

Using as Embedded Resource

To apply a license, you can  load it from file or stream. Another neat way of packaging the license with your application is to include it as an embedded resource into one of the assemblies that calls Aspose.Page for .NET.

To include the file as an embedded resource:

  1. In Visual Studio .NET, include the .lic file into the project by clicking the File menu and selecting Add Existing Item.
  2. Select the file in the Solution Explorer.
  3. In the Properties window, set the Build Action to Embedded Resource.

MergedAPI is the application’s default namespace.

 1// For complete examples and data files, please go to https://github.com/aspose-xps/Aspose.XPS-for-.NET
 2// The path to the documents directory.
 3string dataDir = RunExamples.GetDataDir_GettingStarted();
 4// Initialize license object
 5Aspose.Xps.License license = new Aspose.Xps.License();
 6// Set license
 7license.SetLicense("MergedAPI.Aspose.Total.lic");
 8// Set the value to indicate that license will be embedded in the application
 9license.Embedded = true;
10Console.WriteLine("License set successfully.");

One point which needs consideration - Please note that the embedded resources are included in assembly the way they are added i.e. if you add text file as an embedded resource in the application and open the resultant EXE in notepad, you will see the exact contents of a text file. So when using license file as an embedded resource, anyone can open a .exe file in some simple text editor and see/extract the contents of embedded license.

Therefore, in order to put an extra layer of security when embedding the license with the application, you can compress/encrypt license and after that, you can embed it into the assembly. A free utility DotNetZip ( http://dotnetzip.codeplex.com/) can help to fulfil this requirement. Suppose we have Aspose.Total.NET.lic license file, so let’s make Aspose.Total.NET.lic.zip with password test and embed this zip file into solution. The following code snippet can be used to initialize the license:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2// The path to the documents directory.
 3string dataDir = RunExamples.GetDataDir_GettingStarted();
 4// Initialize license object
 5Aspose.Page.License license = new Aspose.Page.License();
 6// Set license
 7license.SetLicense("MergedAPI.Aspose.Total.NET.lic");
 8// Set the value to indicate that license will be embedded in the application
 9license.Embedded = true;
10Console.WriteLine("License set successfully.");

Metered License

Aspose.Page allows developers to apply metered key. It is a new licensing mechanism. The new licensing mechanism will be used along with existing licensing method. Those customers who want to be billed based on the usage of the API features can use the metered licensing. For more details, please refer to Metered Licensing FAQ section.

A new class Metered has been introduced to apply metered key. Following is the sample code demonstrating how to set metered public and private keys.

1// set metered public and private keys
2Aspose.Page.Metered metered = new Aspose.Page.Metered();
3// Access the setMeteredKey property and pass public and private keys as parameters
4metered.SetMeteredKey(
5    "<type public key here>",
6    "<type private key here>");

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.