How to Apply Windows License Key

Windows | Technical QuestionsSat. 21 Dec. 2024

Before integrating ComPDFKit PDF SDK, please get a license key first, and then follow the below steps to apply the license to your projects.

 

Online License:

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:

bool LicenseVerify()
{
    if (!CPDFSDKVerifier.LoadNativeLibrary())
        return false;

    LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify("Input your license here.", false);
    return (verifyResult == LicenseErrorCode.E_LICENSE_SUCCESS);
}