Apply the License Key
If you haven't get a license key, please check out how to obtain a license key.
ComPDFKit PDF SDK currently supports two authentication methods to verify license keys: online authentication and offline authentication.
Learn about:
What is the authentication mechanism of ComPDFKit's license?
What are the differences between Online Authentication and Offline Authentication?
Copying the License Key
Accurately obtaining the license key is crucial for the application of the license.
In the email you received, locate the
XML
file containing the license key.Open the XML file, and determine the license type based on the
<type>
field. If<type>online</type>
is present, it indicates an online license. If<type>offline</type>
is present or if the field is absent, it indicates an offline license.
Online License:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<license version="1">
<platform>xxxxxx</platform>
<starttime>xxxxxxxx</starttime>
<endtime>xxxxxxxx</endtime>
<type>online</type>
<key>LICENSE_KEY</key>
</license>
Offline License:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<license version="1">
<platform>xxxxxx</platform>
<starttime>xxxxxxxx</starttime>
<endtime>xxxxxxxx</endtime>
<key>LICENSE_KEY</key>
</license>
- Copy the value located at the LICENSE_KEY position within the
<key>LICENSE_KEY</key>
field. This is your license key.
Apply the License Key
Before using any classes from the ComPDFKit PDF SDK, you need to choose the corresponding scheme from the following two options based on the license type and apply the license to your application.
Online License
You can perform online authentication using the following method:
public static bool LicenseVerify()
{
if (!CPDFSDKVerifier.LoadNativeLibrary())
{
return false;
}
LicenseErrorCode status = CPDFSDKVerifier.OnlineLicenseVerify("Input your license here.");
return status == LicenseErrorCode.E_LICENSE_SUCCESS;
}
Furthermore, if you need to confirm the communication status with the server during the current online authentication, you can achieve this by implementing the CPDFSDKVerifier.LicenseRefreshed
callback.:
CPDFSDKVerifier.LicenseRefreshed += CPDFSDKVerifier_LicenseRefreshed;
private void CPDFSDKVerifier_LicenseRefreshed(object sender, ResponseModel e)
{
if(e != null)
{
string message = string.Format("{0} {1}", e.Code, e.Message);
Trace.WriteLine(message);
}
else
{
Trace.WriteLine("Network not connected.");
}
}
Offline License
You can perform offline authentication using the following method:
bool LicenseVerify()
{
if (!CPDFSDKVerifier.LoadNativeLibrary())
return false;
LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify("Input your license here.", false);
return (verifyResult == LicenseErrorCode.E_LICENSE_SUCCESS);
}