Class Metered
Namespace: Aspose.Pdf
Assembly: Aspose.PDF.dll
Provides methods to set metered key.
public class Metered
Inheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
In this example, an attempt will be made to set metered public and private key.
var metered = new Metered();
metered.SetMeteredKey("PublicKey", "PrivateKey");</code></pre>
```csharp
Dim metered As Metered = New Metered
metered.SetMeteredKey("PublicKey", "PrivateKey")
Shows how to activate a Metered license and track credit/consumption.
// Set metered public and private keys
var metered = new Aspose.Pdf.Metered();
metered.SetMeteredKey("PublicKey", "PrivateKey");
//Get current Consumption Credit and Quantity
var wasCredit = Metered.GetConsumptionCredit();
var wasQuantity = Metered.GetConsumptionQuantity();
//Operate using Aspose.Pdf
var doc = new Document();
doc.Pages.Add();
doc.Save(dataDir + "example.pdf");
//Little wait to be sure the transaction completed
System.Threading.Thread.Sleep(10000);
//Get current Consumption Credit and Quantity
var nowCredit = Metered.GetConsumptionCredit();
var nowQuantity = Metered.GetConsumptionQuantity();
//Show Info
Console.WriteLine("Credit: was={0} now={1} difference={2}", wasCredit, nowCredit, nowCredit - wasCredit);
Console.WriteLine("Quantity: was={0} now={1} difference={2}", wasQuantity, nowQuantity, nowQuantity - wasQuantity);
```<pre><code class="lang-csharp">
' Set metered public And private keys
Dim metered = New Aspose.Pdf.Metered()
metered.SetMeteredKey("PublicKey", "PrivateKey")
'Get current Consumption Credit And Quantity
Dim wasCredit = Metered.GetConsumptionCredit()
Dim wasQuantity = Metered.GetConsumptionQuantity()
'Operate using Aspose.Pdf
Dim doc = New Document()
doc.Pages.Add()
doc.Save(dataDir + "example.pdf")
'Little wait to be sure the transaction completed
System.Threading.Thread.Sleep(10000)
'Get current Consumption Credit And Quantity
Dim nowCredit = Metered.GetConsumptionCredit()
Dim nowQuantity = Metered.GetConsumptionQuantity()
'Show Info
Console.WriteLine("Credit: was={0} now={1} difference={2}", wasCredit, nowCredit, nowCredit - wasCredit)
Console.WriteLine("Quantity: was={0} now={1} difference={2}", wasQuantity, nowQuantity, nowQuantity - wasQuantity)
Constructors
Metered()
public Metered()
Methods
GetConsumptionCredit()
Gets consumption credit.
public static decimal GetConsumptionCredit()
Returns
Consumption quantity.
GetConsumptionQuantity()
Gets consumption file size.
public static decimal GetConsumptionQuantity()
Returns
Consumption quantity.
GetProductName()
Get the Product Name.
public string GetProductName()
Returns
Product Name
IsMeteredLicensed()
Check whether metered is licensed.
public static bool IsMeteredLicensed()
Returns
True or false
SetMeteredKey(string, string)
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.
public void SetMeteredKey(string publicKey, string privateKey)
Parameters
publicKey
string
public key
privateKey
string
private key