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:
- Allows converting of PostScript files which size is no more than 500 KB and resulting PDF document in such cases will contain evaluation mark.
- Will not allow manipulating more than 4 XPS elements and resulting document or image in such cases will also contain evaluation mark i.e. “Evaluation Only. Created with Aspose.Page. Copyright 2002-2023 Aspose Pty Ltd” at the top.
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();
10
11// Initialize PsDocument with PostScript file
12PsDocument document = new PsDocument(dataDir + "input.ps");
13
14//check if document is licensed
15if (document.isLicensed())
16 System.out.println("Metered License is set successfully.");
17else
18 System.out.println("Metered License is not set.");
19
20//Initialize options object with default parameters.
21ImageSaveOptions options = new ImageSaveOptions(ImageFormat.PNG);
22
23//Save EPS file as PNG images bytes. One bytes array for one page. In our case we have one page.
24byte[][] imagesBytes = document.saveAsImage(options);
25
26//Save image bytes to file
27FileOutputStream fs = new FileOutputStream(dataDir + "eps_out." + imageFormat.toString().toLowerCase());
28try {
29 fs.write(imagesBytes[0], 0, imagesBytes[0].length);
30} catch (IOException ex) {
31 System.out.println(ex.getMessage());
32} finally {
33 fs.close();
34}
35
36//Now we can check visually if Metered License is applied.
37//If resulting image doesn't contain red evaluation message It means Metered License is applied successfully.