Licensing | Aspose.Page for Java

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-xx.x.jar file and specify the filename, without a path, as shown in the example below.

Apply License using File or Stream Object

The easiest way to apply a license is to put the license file in the same folder as the aspose-page-xx.x.jar file and specify just the file name without a path.

If you use are using any other Aspose for Java component along with Aspose.Page for Java, please specify a complete namespace for License like com.aspose.page.License.

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-xx.x.jar file and specify just the filename without a path.

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.Java.lic.xml” pass that filename to the com.aspose.page.License.setLicense(…) method. The license file can be specified for Aspose.Page for Java or you can use Aspose.Total for Java license file.

1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Java
2// instantiate License object
3com.aspose.page.License license = new com.aspose.page.License();
4// license file path information
5license.setLicense("Aspose.Total.Java.lic");

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-Java
2// Initialize License Instance
3com.aspose.page.License license = new com.aspose.page.License();
4// Set license from Stream
5license.setLicense(new java.io.FileInputStream("Aspose.Total.Java.lic"));

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
 2com.aspose.page.Metered metered = new com.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>");
 7
 8// The path to the documents directory.
 9String dataDir = Utils.getDataDir();
10ImageFormat imageFormat = ImageFormat.PNG;
11// Initialize PostScript input stream
12FileInputStream psStream = new FileInputStream(dataDir + "input.ps");
13
14PsDocument document = new PsDocument(psStream);
15
16//check if document is licensed
17if (document.isLicensed())
18    System.out.println("Metered License is set successfully.");
19else
20  System.out.println("Metered License is not set.");
21
22//Initialize options object with default parameters.
23ImageSaveOptions options = new ImageSaveOptions();
24
25//Initialize ImageDevice object with default parameters.
26com.aspose.eps.device.ImageDevice device = new com.aspose.eps.device.ImageDevice();
27
28//Save EPS file as image
29try {
30    document.save(device, options);
31} finally {
32    psStream.close();
33}
34
35//Get images bytes. One bytes array for one page. In our case we have one page.
36byte[][] imagesBytes = device.getImagesBytes();
37
38//Save image bytes to file
39FileOutputStream fs = new FileOutputStream(dataDir + "eps_out." + imageFormat.toString().toLowerCase());
40try {
41    fs.write(imagesBytes[0], 0, imagesBytes[0].length);
42} catch (IOException ex) {
43    System.out.println(ex.getMessage());
44} finally {
45    fs.close();
46}
47
48//Now we can check visually if Metered License is applied.
49//If resulting image doesn't contain red evaluation message It means Metered License is applied successfully.
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.