How to set a development license

Set a development license

Once you obtain a development license, you can find your license information in the customer portal. Please follow the steps below to use the development license:

  1. Activate a development license

    Please click on the “Activate Now” link to start activating the selected development license key.

    It brings you to the following page. Just click on the “Activate” button to activate the license key.

    Now you can see the Status, Quota and Expiration Date of the activated license key.

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

  2. Set a development license key in your program

    Please refer to the following code examples to set the activated license key(s) in your program via the initLicenseFromServer and initLicenseFromLicenseContent APIs.

    Dynamsoft provides two methods for the development machine to use the barcode SDK with the license sent. One method is to use initLicenseFromServer to connect to Dynamsoft hosted server directly all the time. The other method allows you to use the license offline. You will need to use the initLicenseFromServer API to connect to Dynamsoft Hosted server to obtain the license information, and then use the outputLicenseToString API to get the information of the license and store the information, then use initLicenseFromServerContent API to use the SDK offline with the license sent.

    The code on how to implement the second method will be shown below using C/C++/C#/Java. The key is to get the license information and then store the information in the lcoal machine to use Dynamsoft Barcode Reader SDK offline.

C

    //c
    void* _br = NULL;
    int iLicMsg = -1;
    char info[512];
    _br = DBR_CreateInstance();
    FILE *file;
    //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 = 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 successfully: %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 other 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;
     } 
     }



    //decode barcodes happens here
    //....

    DBR_DestroyInstance(_br);

C++

    //c++
    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 in 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 successfully: %d\r\n%s\r\n", iLicMsg, DBR_GetErrorString(iLicMsg));
         return iLicMsg;
        }
       //if you wish to use SDK offline
         //store the license information in txt other 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, DBR_GetErrorString(iLicMsg));
         return iLicMsg;
        }
      }
    //decode barcodes happens here
    //....
    delete reader;

C#

    //.NET
    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
    //....

Java

    //java
    int iLicMsg = -1;
    File file = new File("Put your file path here");
    BarcodeReader reader = 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 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; 
    }
    }

Note:

  • The first parameter(for C, it is 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 you need to use multiple development license keys to support different barcode formats (e.g., 1D and QR) in the same mobile application, please separate the license keys by a semicolon (;).

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

  • With the development license, you can develop and test your application on your dev machine. Please note that your dev machine will be counted as one development device and registered on the server.

  • If you need to increase the quota of your existing development license key, please contact sales@dynamsoft.com.

results matching ""

    No results matching ""