Use a Development License

Different methods are used for setting trial and full license keys. In the demo or sample applications, we use .InitLicense() or .ProductKeys to set trial license keys. For the purchased version, you need to use initLicenseFromServer() or initLicenseFromLicenseContent() to complete the license registration.

You can use a development license by following the steps below:

  1. Activate a development license
  2. Register the development license key

Activate a development license

Once you obtain a Development License, you can find your license information at Customer Portal > License Center > Barcode Reader SDK.

To activate a development license (8-digit key), click the Activate Now link beside it.

On the following popup window, click the Yes button.

Then you can see the status, quota, used seats and expiration date of the activated license key.

You can repeat the above steps to activate other license keys.

Register the development license key

Here are the possible options to register a development license:

Connect to Dynamsoft server once and use the SDK offline

If you wish to use the SDK offline after activating, please follow the steps below:

  1. Use initLicenseFromServer() to connect to Dynamsoft Hosted server (or your own server) to obtain the license information. The machine needs Internet connection to complete the device registration for the first time.
  2. Use outputLicenseToString() to get the information of the license and store the information to the development machine.
  3. Use initLicenseFromLicenseContent() API to register the license.

    C
    C++
    C#
    Java
    Python
    void* _br = NULL;
    int iLicMsg = -1;
    char info[512];
    _br = DBR_CreateInstance();
    FILE *file;
    // Check if there is a license file on the local machine. If yes, use the local license file; Otherwise, connect to Dynamsoft Hosted server to verify the license. 
    if ((file = fopen("license.txt", "r")) == NULL) 
    {
      // Connect to the Dynamsoft server to verify the license
      iLicMsg = DBR_InitLicenseFromServer(_br, "", "licenseKey1;licenseKey2"); 
      // The second parameter is the IP of the license server. Leaving it  empty ("") means it will connect to Dynamsoft License Server for online  verification automatically.
      // If error occurs to the license
      if (iLicMsg != DBR_OK) {
         printf("Failed to initialize the license: %d\r\n%s\r\n", iLicMsg, DBR_GetErrorString(iLicMsg));
         return iLicMsg;
      } 
      DBR_OutputLicenseToString(_br, info, 512);
      // If you wish to use SDK offline, store the license information in txt or other format
      FILE *fp = fopen("license.txt", "w");
      if (fp == 0){
         printf("can't open file\n");
         return 0;
      }
      fwrite(info, sizeof(char) * 512, 1, fp);
      fclose(fp);
    }
    else{
      // Use the local license file and use Dynamsoft Barcode Reader SDK offline
      FILE *fp = fopen("license.txt", "r");
      fscanf(fp, "%s", &info);
      fclose(fp);
      iLicenMsg = DBR_InitLicenseFromLicenseContent(_br, "licenseKey1;licenseKey2",  info);
      // If error occurs to the license
      if (iLicMsg != DBR_OK) {
         printf("Failed to initialize the license successfully: %d\r\n%s\r\n", iLicMsg, DBR_GetErrorString(iLicMsg));
         return iLicMsg;
      } 
    }
    
    // Barcode decoding happens here
    //....
    DBR_DestroyInstance(_br);
    CBarcodeReader* reader = new CBarcodeReader();
    int iLicMsg = -1;
    char info[512];
    string filePath= "license.txt";
    // To be able to use the license key offline, you need to store the license file obtained from Dynamsoft server once you use the API, InitLicenseFromServer.
    fstream licenseFile;
    licenseFile.open(filePath, ios::in);
    // Check if there is a license file on the local machine. If not, connect to Dynamsoft Hosted server to verify the license. Otherwise, use the local license file.
    if (!licenseFile)  
    {
       // Connect to Dynamsoft server to verify the license. 
       iLicMsg = reader->InitLicenseFromServer("", "licenseKey1;licenseKey2");
       // The first parameter is the IP of the license server. Leaving it empty ("") means it will connect to Dynamsoft License Server for online verification automatically.
           
       // If error occurs to the license
       if (iLicMsg != DBR_OK) 
       {
          printf("Failed to initialize the license: %d\r\n%s\r\n", iLicMsg, CBarcodeReader::GetErrorString(iLicMsg));
          return iLicMsg;
       }
       // If you wish to use SDK offline, store the license information in TXT or other format
       reader->OutputLicenseToString(info, 512);
       ofstream licFileOut(filePath);
       licFileOut << info;
       licFileOut.close();
    }
    else
    {
       // Use the local license file and use Dynamsoft Barcode Reader SDK offline
       ifstream licFileIn(filePath);
       licFileIn >> info;
       licFileIn.close();
       iLicMsg = reader->InitLicenseFromLicenseContent("licenseKey1;licenseKey2", info);
       // If error occurs to the license
       if (iLicMsg != DBR_OK) 
       {
          printf("Failed to initialize the license successfully: %d\r\n%s\r\n", iLicMsg, CBarcodeReader::GetErrorString(iLicMsg));
          return iLicMsg;
       }
    }
    // Decode barcodes happens here
    //....
    delete reader;
    int iLicMsg = -1;
    string path = @"Put your file path here";
    // To be able to use the license key offline, you need to store the license file obtained from Dynamsoft server once you use the API, InitLicenseFromServer.
    BarcodeReader _br = new BarcodeReader();
    // Check if there is a license file in the local machine. If not, connect to Dynamsoft Hosted server to verify the license. Otherwise, use the local license file.
    if (!File.Exists(path))
    {
       // Connect to Dynamsoft server to verify the license
       iLicMsg = _br.InitLicenseFromServer("", "licenseKey1;licenseKey2");
       // The first parameter is the string of the license server. Leaving it empty ("") means it will connect to Dynamsoft License Server for online verification.
       if(iLicMsg != 0)
       {
          Console.WriteLine("License error Code:",iLicMsg);
          return; 
       }
       // If you wish to use SDK offline, store the license information as txt format
       string license = _br.OutputLicenseToString();
       File.WriteAllText(path, license);
    }
    else{
       // Use the local license file and use Dynamsoft Barcode Reader SDK 
       string license = File.ReadAllText(path);
       iLicMsg = _br.InitLicenseFromLicenseContent("licenseKey1;licenseKey2",license);
       if(iLicMsg != 0)
       {
          Console.WriteLine("Error Code:",iLicMsg);
          return; 
       }
    }
    // Decode barcodes happens here
    //....
    int iLicMsg = -1;
    File file = new File("Put your file path here");
    BarcodeReader reader = new BarcodeReader();
    // Check if there is a license file on the local machine. If not, connect to Dynamsoft Hosted server to verify the license. Otherwise, use the license file.
    if (!file.exists()){
       // Connect to Dynamsoft server to verify the license. 
       iLicMsg = reader.initLicenseFromServer("", "licenseKey1;licenseKey2");// The first parameter is the string of the license server. Leaving it empty ("") means it will connect to Dynamsoft License Server for online verification.
       if(iLicMsg != 0)
       {
          System.out.println("License error Code:"+iLicMsg);
          return; 
       }
       // If you wish to use SDK offline, store the license information as txt format or in other format
       String license = reader.outputLicenseToString();
       PrintWriter pw = new PrintWriter(file);
       pw.print(license);
       pw.close();
    }
    else{
       // Use the local license file and use Dynamsoft Barcode Reader SDK 
       byte[] encoded = Files.readAllBytes(file.toPath());
       String license = new String(encoded, "utf-8");
       iLicMsg = reader.initLicenseFromLicenseContent("licenseKey1;licenseKey2",license);
       if(iLicMsg != 0)
       {
          System.out.println("License error Code:"+iLicMsg);
          return; 
       }
    }
    def initLicenseFromServer(pLicenseServer,pLicenseKey):
        dbr.initLicenseFromServer(pLicenseServer,pLicenseKey)
    def initLicenseFromLicenseContent(pLicenseKey,pLicenseContent):
        dbr.initLicenseFromLicenseContent(pLicenseKey,pLicenseContent)
    def outputLicenseToString():
        content = dbr.outputLicenseToString()
        return content
    
    #Check if there is a license file on the local machine. If not, connect to Dynamsoft Hosted server to verify the license. Otherwise, use the local license file.
    if os.path.exists(license.txt):
       #Use the local license file to activate the SDK 
       with open("license.txt","r") as f:
          pLicenseContent = f.read()
       initLicenseFromLicenseContent("licenseKey1",pLicenseContent)
    else:
       initLicenseFromServer("","licenseKey1")
       #If you wish to use SDK offline, store the license information as .txt or other format
       content=outputLicenseToString()
       with open("license.txt","w") as f:
          f.write(content)

Note:

  • The license verification process on the development machine can be a one-time process. Once it is registered, the registration file for this specific device can be returned and stored to the machine.

  • If you need to increase the quota of your existing license key, please contact us.

Always connect to Dynamsoft server for license verification

If your development machine can access Internet all the time, you can use the initLicenseFromServer() method to register the development license. It will connect to Dynamsoft server for license verification each time you use the SDK.

C
C++
C#
Java
Python
void* _br = NULL;
int iLicMsg = -1;
_br = DBR_CreateInstance();
// Connect to the Dynamsoft server to verify the license
iLicMsg = DBR_InitLicenseFromServer(_br, "", "licenseKey1;licenseKey2"); 
// If error occurs to the license
if (iLicMsg != DBR_OK) {
   printf("Failed to initialize the license: %d\r\n%s\r\n", iLicMsg, DBR_GetErrorString(iLicMsg));
   return iLicMsg;
} 
// Barcode decoding happens here
//....
DBR_DestroyInstance(_br);
CBarcodeReader* reader = new CBarcodeReader();
int iLicMsg = -1;
// Connect to Dynamsoft server to verify the license. 
iLicMsg = reader->InitLicenseFromServer("", "licenseKey1;licenseKey2");
// If error occurs to the license
if (iLicMsg != DBR_OK) 
{
   printf("Failed to initialize the license: %d\r\n%s\r\n", iLicMsg, CBarcodeReader::GetErrorString(iLicMsg));
   return iLicMsg;
}
// Decode barcodes happens here
//....
delete reader;
int iLicMsg = -1;
BarcodeReader _br = new BarcodeReader();
// Connect to Dynamsoft server to verify the license. 
iLicMsg = _br.InitLicenseFromServer("", "licenseKey1;licenseKey2");
if(iLicMsg != 0)
{
   Console.WriteLine("License error Code:",iLicMsg);
   return; 
}
// Decode barcodes happens here
//....
_br.Dispose();
int iLicMsg = -1;
BarcodeReader reader = new BarcodeReader();
// Connect to Dynamsoft server to verify the license. 
iLicMsg = reader.initLicenseFromServer("", "licenseKey1;licenseKey2");
if(iLicMsg != 0)
{
   System.out.println("License error Code:"+iLicMsg);
   return; 
}
def initLicenseFromServer(pLicenseServer,pLicenseKey):
    dbr.initLicenseFromServer(pLicenseServer,pLicenseKey)
#Check if there is a license file on the local machine. If not, connect to Dynamsoft Hosted server to verify the license. Otherwise, use the local license file.
if os.path.exists(license.txt):
   #Use the local license file to activate the SDK 
   with open("license.txt","r") as f:
      pLicenseContent = f.read()
   initLicenseFromLicenseContent("licenseKey1",pLicenseContent)
else:
   initLicenseFromServer("","licenseKey1")
   #If you wish to use SDK offline, store the license information as .txt or other format
   content = outputLicenseToString()
   with open("license.txt","w") as f:
      f.write(content)

No Internet connection

If your machine is not allowed to access Internet, you can follow the steps below to manually register the device and get the license content.

  1. Log in Customer Portal and go to License Center > Barcode Reader SDK. Click the number under Used.

  2. Click the Add button to add a device.

  3. Get amd run the Dynamsoft tool on the device to be registered and get the machine ID.

    For Windows:

    Download MachineIDGenerator.exe and run it. The returned string, e.g. tZRk-6qb2-sEyE-wcz7-jf6j-8DH/-Di3u-zjSv-G86f-ol3x, is the machine ID.

    For Linux:

    Download MachineIDGenerator.tar.gz and unzip it. Open Terminal and type ./MachineIDGenerator. The returned string, e.g. iJpN-Cajc-qQip-Sl50-NEX+-z1dJ-XmmV-lS9O-G86f-ol3x, is the machine ID.

  4. Input the machine ID in the text box and click Continue.

    Then the license file (.dslf), which contains the license content, will be downloaded automatically.

  5. Use the initLicenseFromLicenseContent(licenseKey, licenseContent) API to activate the SDK offline.

    licenseKey: 8-digit key in the customer portal

    licenseContent: the string in the .dslf file

    C
    C++
    C#
    Java
    Python
    void* _br = NULL;
    int iLicMsg = -1;
    _br = DBR_CreateInstance();
    // Use the SDK offline
    iLicMsg = DBR_InitLicenseFromLicenseContent(_br, "licenseKey1", "LicenseContent")); 
    // If error occurs to the license
    if (iLicMsg != DBR_OK) {
       printf("Failed to initialize the license: %d\r\n%s\r\n", iLicMsg, DBR_GetErrorString(iLicMsg));
       return iLicMsg;
    } 
    // Barcode decoding happens here
    //....
    DBR_DestroyInstance(_br);
    CBarcodeReader* reader = new CBarcodeReader();
    int iLicMsg = -1;
    // Use the SDK offline 
    iLicMsg = reader->InitLicenseFromLicenseContent("licenseKey1", "LicenseContent");
    // If error occurs to the license
    if (iLicMsg != DBR_OK) 
    {
       printf("Failed to initialize the license: %d\r\n%s\r\n", iLicMsg, CBarcodeReader::GetErrorString(iLicMsg));
       return iLicMsg;
    }
    // Decode barcodes happens here
    //....
    delete reader;
    int iLicMsg = -1;
    BarcodeReader _br = new BarcodeReader();
    // Use the SDK offline 
    iLicMsg = _br.InitLicenseFromLicenseContent("licenseKey1", "LicenseContent");
    if(iLicMsg != 0)
    {
       Console.WriteLine("License error Code:",iLicMsg);
       return; 
    }
    // Decode barcodes happens here
    //....
    _br.Dispose();
    int iLicMsg = -1;
    BarcodeReader reader = new BarcodeReader();
    // Use the SDK offline
    iLicMsg = reader.initLicenseFromLicenseContent("", "licenseKey1", "LicenseContent");
    if(iLicMsg != 0)
    {
       System.out.println("License error Code:"+iLicMsg);
       return; 
    }
    def initLicenseFromLicenseContent(plicenseKey, pLicenseContent):
       dbr.initLicenseFromLicenseContent(plicenseKey, pLicenseContent)

If you run into any issues, please contact Dynamsoft Support.

results matching ""

    No results matching ""