var metered = new Metered();
metered.SetMeteredKey("PUBLIC_KEY", "PRIVATE_KEY");
decimal consumed = Metered.GetConsumptionQuantity();
decimal credit = Metered.GetConsumptionCredit();
bool isLicensed = Metered.IsMeteredLicensed();
var doc = new Document("test.docx");
doc.Save("output.pdf");
Cause
If GetConsumptionCredit()
returns 0 after applying a metered license, it could be due to several reasons. The most common cause is that the consumption data has not been successfully uploaded to the Aspose server, which can occur if there is a connectivity issue or if the application has not been running long enough to accumulate any usage data.
Solution
To troubleshoot this issue, follow these steps:
-
Check Internet Connectivity: Ensure that your application has a stable internet connection, as the metered licensing mechanism requires communication with Aspose servers.
-
Delay After Operations: After performing operations with Aspose.Words, introduce a delay (e.g.,
Thread.Sleep(10000)
) to allow time for the consumption data to be sent to the server. This is important because the library does not send usage data immediately. -
Reapply Metered Key: If the application has been running for more than 24 hours without a successful upload, the license may revert to evaluation mode. In this case, you should reapply the metered key using
SetMeteredKey()
. -
Check License Status: Use
IsMeteredLicensed()
to verify if the metered license is still valid. If it returns false, you need to reapply the metered key.
Code
Here’s a sample code snippet demonstrating how to implement these steps:
var metered = new Metered();
metered.SetMeteredKey("YOUR_PUBLIC_KEY", "YOUR_PRIVATE_KEY");
Document doc = new Document("test.docx");
doc.Save("output.pdf");
// Wait for a while to allow consumption data to be sent
System.Threading.Thread.Sleep(10000);
decimal consumed = Metered.GetConsumptionQuantity();
decimal credit = Metered.GetConsumptionCredit();
bool isLicensed = Metered.IsMeteredLicensed();
Console.WriteLine($"Consumption Quantity: {consumed}");
Console.WriteLine($"Consumption Credit: {credit}");
Console.WriteLine($"Is Metered Licensed: {isLicensed}");
Next Steps
- Run the application and monitor the output for the consumption quantity and credit.
- If the issue persists, check the Aspose support forums or documentation for further assistance.
Please let me know if you need any more help!
please check above output screenshot attached , issue still persist with output
Consumption Quantity: 0.8405
Consumption Credit: 0
Is Metered Licensed: True
@PiramalFinance Aspose Metered Licensing mechanism does not send the usage data to purchase server every time.
For this case, could you please change your code as below for test:
var consumptionCreditBefore = Aspose.Words.Metered.GetConsumptionCredit();
var doc = new Aspose.Words.Document(@"C:\Temp\Test.docx");
doc.Save(@"C:\Temp\Metered.Usage.pdf");
System.Threading.Thread.Sleep(10000);
var consumptionCreditAfter = Aspose.Words.Metered.GetConsumptionCredit();
var consumptionCredit = consumptionCreditAfter - consumptionCreditBefore;
I got output as
consumptionCreditBefore = 0
consumptionCreditAfter = 0
consumptionCredit =0
Please check issue , i need to remove watermark from my generated pdfs.
@PiramalFinance I received information using the GetConsumptionCredit for one of our Metered licenses. Could you provide information about your license? What product did you purchase? This behavior can be expected if the license is unlimited.