com.aspose.words

Class Metered

  • java.lang.Object
    • com.aspose.words.Metered
public class Metered 
extends java.lang.Object

Provides methods to set metered key.

Example:

In this example, an attempt will be made to set metered public and private key the component jar file:
            Metered matered = new Metered();
            matered.setMeteredKey("PublicKey", "PrivateKey");
            

Example:

Shows how to activate a Metered license and track credit/consumption.
// Set a public and private key for a new Metered instance
Metered metered = new Metered();
metered.setMeteredKey("MyPublicKey", "MyPrivateKey");

// Print credit/usage 
System.out.println(MessageFormat.format("Credit before operation: {0}", Metered.getConsumptionCredit()));
System.out.println(MessageFormat.format("Consumption quantity before operation: {0}", Metered.getConsumptionQuantity()));

// Do something
Document doc = new Document(getMyDir() + "Document.docx");

// Print credit/usage to see how much was spent
System.out.println(MessageFormat.format("Credit after operation: {0}", Metered.getConsumptionCredit()));
System.out.println(MessageFormat.format("Consumption quantity after operation: {0}", Metered.getConsumptionQuantity()));

Constructor Summary
Metered()
Initializes a new instance of this class.
 
Method Summary
static java.math.BigDecimalgetConsumptionCredit()
Gets consumption credit
static java.math.BigDecimalgetConsumptionQuantity()
Gets consumption file size
voidsetMeteredKey(java.lang.String publicKey, java.lang.String privateKey)
Sets metered public and private key. If you purchase metered license, when start application, this API should be called, normally, this is enough. However, if always fail to upload consumption data and exceed 24 hours, the license will be set to evaluation status, to avoid such case, you should regularly check the license status, if it is evaluation status, call this API again.
 

    • Constructor Detail

      • Metered

        public Metered()
        Initializes a new instance of this class.

        Example:

        Shows how to activate a Metered license and track credit/consumption.
        // Set a public and private key for a new Metered instance
        Metered metered = new Metered();
        metered.setMeteredKey("MyPublicKey", "MyPrivateKey");
        
        // Print credit/usage 
        System.out.println(MessageFormat.format("Credit before operation: {0}", Metered.getConsumptionCredit()));
        System.out.println(MessageFormat.format("Consumption quantity before operation: {0}", Metered.getConsumptionQuantity()));
        
        // Do something
        Document doc = new Document(getMyDir() + "Document.docx");
        
        // Print credit/usage to see how much was spent
        System.out.println(MessageFormat.format("Credit after operation: {0}", Metered.getConsumptionCredit()));
        System.out.println(MessageFormat.format("Consumption quantity after operation: {0}", Metered.getConsumptionQuantity()));
    • Method Detail

      • getConsumptionCredit

        public static java.math.BigDecimal getConsumptionCredit()
                                                   throws java.lang.Exception
        Gets consumption credit
        Returns:
        consumption quantity

        Example:

        Shows how to activate a Metered license and track credit/consumption.
        // Set a public and private key for a new Metered instance
        Metered metered = new Metered();
        metered.setMeteredKey("MyPublicKey", "MyPrivateKey");
        
        // Print credit/usage 
        System.out.println(MessageFormat.format("Credit before operation: {0}", Metered.getConsumptionCredit()));
        System.out.println(MessageFormat.format("Consumption quantity before operation: {0}", Metered.getConsumptionQuantity()));
        
        // Do something
        Document doc = new Document(getMyDir() + "Document.docx");
        
        // Print credit/usage to see how much was spent
        System.out.println(MessageFormat.format("Credit after operation: {0}", Metered.getConsumptionCredit()));
        System.out.println(MessageFormat.format("Consumption quantity after operation: {0}", Metered.getConsumptionQuantity()));
      • getConsumptionQuantity

        public static java.math.BigDecimal getConsumptionQuantity()
        Gets consumption file size
        Returns:
        consumption quantity

        Example:

        Shows how to activate a Metered license and track credit/consumption.
        // Set a public and private key for a new Metered instance
        Metered metered = new Metered();
        metered.setMeteredKey("MyPublicKey", "MyPrivateKey");
        
        // Print credit/usage 
        System.out.println(MessageFormat.format("Credit before operation: {0}", Metered.getConsumptionCredit()));
        System.out.println(MessageFormat.format("Consumption quantity before operation: {0}", Metered.getConsumptionQuantity()));
        
        // Do something
        Document doc = new Document(getMyDir() + "Document.docx");
        
        // Print credit/usage to see how much was spent
        System.out.println(MessageFormat.format("Credit after operation: {0}", Metered.getConsumptionCredit()));
        System.out.println(MessageFormat.format("Consumption quantity after operation: {0}", Metered.getConsumptionQuantity()));
      • setMeteredKey

        public void setMeteredKey(java.lang.String publicKey, java.lang.String privateKey)
        Sets metered public and private key. If you purchase metered license, when start application, this API should be called, normally, this is enough. However, if always fail to upload consumption data and exceed 24 hours, the license will be set to evaluation status, to avoid such case, you should regularly check the license status, if it is evaluation status, call this API again.
        Parameters:
        publicKey - public key
        privateKey - private key

        Example:

        Shows how to activate a Metered license and track credit/consumption.
        // Set a public and private key for a new Metered instance
        Metered metered = new Metered();
        metered.setMeteredKey("MyPublicKey", "MyPrivateKey");
        
        // Print credit/usage 
        System.out.println(MessageFormat.format("Credit before operation: {0}", Metered.getConsumptionCredit()));
        System.out.println(MessageFormat.format("Consumption quantity before operation: {0}", Metered.getConsumptionQuantity()));
        
        // Do something
        Document doc = new Document(getMyDir() + "Document.docx");
        
        // Print credit/usage to see how much was spent
        System.out.println(MessageFormat.format("Credit after operation: {0}", Metered.getConsumptionCredit()));
        System.out.println(MessageFormat.format("Consumption quantity after operation: {0}", Metered.getConsumptionQuantity()));