Evaluation Limitations and Licensing of GroupDocs.Viewer
You can easily download GroupDocs.Viewer for evaluation. The evaluation download is the same as the purchased download. The evaluation version simply becomes licensed when you add a few lines of code to apply the license. You will face following limitations while using the API without the license:
- Only first 2 pages are processed.
- Trial badges are placed in the document on the top of each page.
The license file contains details such as the product name, number of developers it is licensed to, subscription expiry date and so on. It contains the digital signature, so don’t modify the file. Even inadvertent addition of an extra line break into the file will invalidate it. You need to set a license before utilizing GroupDocs.Viewer API if you want to avoid its evaluation limitations.
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 GroupDocs.Viewer.jar file and specify the file name, without a path, as shown in the examples below.
Setting License from File
The code below will explain how to set product license.
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java // Setup license. License license = new License(); license.setLicense(licensePath);
Setting License from Stream
The following example shows how to load a license from a stream.
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java InputStream fileStream = new FileInputStream("GroupDocs.Viewer.lic"); License license = new License(); license.setLicense(fileStream); fileStream.close();
Setting Metered License
Here are the simple steps to use the Metered class.
- Create an instance of Metered class.
- Pass public & private keys to setMeteredKey(…) method.
- Do processing (perform task).
- call method getConsumptionQuantity(…) of the Metered class.
- It will return the amount/quantity of API requests that you have consumed so far.
- call method getConsumptionCredit(…) of the Metered class.
- It will return the credit that you have consumed so far.
Following is the sample code demonstrating how to use Metered class.
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java String publicKey = ""; // Your public license key String privateKey = ""; // Your private license key Metered metered = new Metered(); metered.setMeteredKey(publicKey, privateKey); // Get amount (MB) consumed double amountConsumed = Metered.getConsumptionQuantity(); System.out.println("Amount (MB) consumed: " + amountConsumed); // Get count of credits consumed double creditsConsumed = Metered.getConsumptionCredit(); System.out.println("Credits consumed: " + creditsConsumed);