How to set a runtime license

Obtain a runtime license

Once you finish your development and testing with the Development license, you will need to purchase a runtime license for distribution or deployment.

If you haven't purchased a runtime license for your application, you can purchase it via our online store or send your purchase order to sales@dynamsoft.com. If you want to receive a quote, please submit a request via this page.

After purchase, you can find your license information in the customer portal. Please follow the steps below to activate the runtime license:

For Desktop/Embedded Device/Mobile App

1. Activate a runtime license

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

It brings you to the following page. Just click on the “Activate” button to activate the license key. If you prefer to host the service on your own server, please contact us for the guide.

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 runtime license key in your program

Please refer to the following sample code to set the activated license key(s) in your application via the initLicenseFromServer API and initLicenseFromLicenseContent.

The client machine will need to use the initLicenseFromServer API to connect to Dynamsoft Hosted server or your own 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 initLicenseFromServer and initLicenseFromLicenseContent APIs will be shown below using C/C++/C#/Java/Objective-C. The key is to get the license information and then use the license information to use our 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("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; 
    }
    }

iOS

    -(id)initWithLicenseFromServer:(NSString*)serverURL LicenseKey:(NSString*)licenseKey
    {
       self = [super init];
       if(self){
          m_barcodeReader = [[DynamsoftBarcodeReader alloc] initWithLicenseFromServer:@"" licenseKey:licenseKey verificationDelegate:self];
          [self MemberInitialize];
          }
       return self;
    }

Android

    mbarcodeReader = new BarcodeReader();
    String strLicenseKey ="put your license here";
    if(strLicenseKey !=null){
      mBarcodeReader.initLicenseFromServer("",strLicenseKey, new DBRServerLicenseVerificationListener() {
         @Override
          public void licenseVerificationCallback(boolean isSuccess, Exception error) {
          if (!isSuccess) {
            Log.e("DBR", "DBR license verify failed due to " + error.getMessage());
             } 
          }
       });

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 runtime license keys to support different barcode formats (e.g., 1D and QR) in the same application, please separate the license keys by a semicolon (;).

  • The license verification process on the end user device can be a one-time process. Once a device is registered, the registration file for this specific device can be automatically returned and stored in the device. After that, the registered device is allowed to scan barcodes without a network connection, until the expiration date of the runtime license key. Once the license is expired, the returned results of barcode will include "*".

  • Please don't use the runtime license for the development. If you continue your development/testing work on your development or test machine with the runtime license, your dev or test machine will be counted as a consumed device and registered on the server.

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

  1. Remove the free trial license

30-day free trial

When you test with our 30-day free trial SDK, a trial license key is set in the program via the following APIs:

C:

    DBR_InitLicense(hBarcode, "t0068NQAAAI8+mMcYRNwmijAzExhq******");

C++:

    CBarcodeReader reader;
    reader.InitLicense("t0068NQAAAI8+mMcYRNwmijAzExhq******");

C#:

    BarcodeReader reader = new BarcodeReader();
    reader.ProductKeys = "t0068NQAAAI8+mMcYRNwmijAzExhq******";

VB.NET

    Dim reader As BarcodeReader = New Dynamsoft.Barcode.BarcodeReader()
    reader.ProductKeys = "t0068NQAAAI8+mMcYRNwmijAzExhq******"

iOS:

    BarcodeReader *br;
    br = [[BarcodeReader alloc] initWithLicense:@"t0068NQAAAI8+mMcYRNwmijAzExhq******"];

Android:

    BarcodeReader mBarcodeReader;
    mBarcodeReader = new BarcodeReader();
    mBarcodeReader.initLicense("t0068NQAAAI8+mMcYRNwmijAzExhq******");

Now that you’ve already purchase a full version license, please comment out the code after you get the runtime license.

Note:

  • No other code change nor re-installation is required to upgrade from the free trial version to the purchased version.

For Server-Based/JavaScript Edition App

If you finished the development and testing using the development license, and wish to make your application available to your clients, you will need to comment out InitLicenseFromServer and use InitLicense instead. Below is the code snippet for reference:

C:

    // DBR_InitLicenseFromServer(hBarcode, "", "DevelopmentLicenseKey");
    DBR_InitLicense(hBarcode, "f0068NQAAAI8+mMcYRNwmijAzExhq******");

C++:

    CBarcodeReader reader;
    // reader.InitLicenseFromServer("", "DevelopmentLicenseKey");
    reader.InitLicense("f0068NQAAAI8+mMcYRNwmijAzExhq******");

C#:

 // C#
    BarcodeReader reader = new BarcodeReader();
    // reader.InitLicenseFromServer("", "DevelopmentLicenseKey");
    reader.ProductKeys  = "f0068NQAAAI8+mMcYRNwmijAzExhq******;f0068NQAAAIeI8yyQAGUkz******";

VB.NET:

    Dim reader As BarcodeReader = New Dynamsoft.Barcode.BarcodeReader()
    ' reader.InitLicenseFromServer("", "DevelopmentLicenseKey");
    reader.ProductKeys  = "f0068NQAAAI8+mMcYRNwmijAzExhq******;f0068NQAAAIeI8yyQAGUkz******"

PHP:

    // PHP
    $br = new BarcodeReader();
    // $br->initLicenseFromServer("", "DevelopmentLicenseKey");
    $br->initLicense("f0068NQAAAI8+mMcYRNwmijAzExhq******;f0068NQAAAIeI8yyQAGUkz******");

Java:

    BarcodeReader mBarcodeReader = new BarcodeReader();
    // mBarcodeReader.initLicenseFromServer("", "DevelopmentLicenseKey");
    mBarcodeReader.initLicense("f0068NQAAAI8+mMcYRNwmijAzExhq******;f0068NQAAAIeI8yyQAGUkz******");

JavaScript Edition SDK:

    // In the dynamsoft.barcodereader.js file, just replace the trial license with a full license.
    BarcodeReader.licenseKey = "f0068NQAAAI8+mMcYRNwmijAzExhq******;f0068NQAAAIeI8yyQAGUkz******";

results matching ""

    No results matching ""