setLicenseUri Method

Summary

Sets the runtime license for LEADTOOLS from a URI and unlocks support for optional features such as LEADTOOLS Imaging Pro, Document, and Medical capabilities.

Syntax
TypeScript
JavaScript
setLicenseUri = function( 
   licenseUri, 
   developerKey, 
   completed 
) 
static setLicenseUri( 
   licenseUri: string, 
   developerKey: string, 
   completed: (arg: SetLicenseUriResult) => any 
): void; 

Parameters

licenseUri

The URI to the license text. If null, the license file is requested from the RasterSupport.licenseDirectory.

developerKey

String containing the developer key. If null, the developer key is requested from the RasterSupport.licenseDirectory.

This parameter can also be a URL to the file containing the developer key on a server.

completed

A callback to be run once when the license check occurs. The callback receives one parameter of type SetLicenseUriResult containing the status of the operation.

Remarks

After you have obtained a runtime license and a developer key, call RasterSupport.setLicenseUri, RasterSupport.setLicenseBuffer or RasterSupport.setLicenseText at the start of your application to set the license to enable LEADTOOLS and disable the nag message.

You must use this method to set the runtime license for LEADTOOLS and to unlock support for any optional features that you have licensed. If you do not set a RELEASE runtime license, your application will display a nag message dialog at runtime, indicating that you have developed the application without a valid runtime license.

The LEADTOOLS JavaScript license is typically provided in a LEADTOOLS.lic.txt file and the developer key is typically provided in a LEADTOOLS.lic.key.txt file.

Setting the License

To set a license successfully, call this method with one of the following:

Method 1

By creating a folder on the server hosting the application and copy LEADTOOLS.lic.txt and LEADTOOLS.lic.key.txt into it. For instance, assuming myserver is the root of the application:

myserver/myapp/LEADTOOLS/LEADTOOLS.lic.txt 
myserver/myapp/LEADTOOLS/LEADTOOLS.lic.key.txt 

Parameter Value
licenseUri https://myserver/myapp/LEADTOOLS/LEADTOOLS.lic.txt
developerKey null since LEADTOOLS will try to automatically find the developer key file in the same folder as the license file

Example

var licenseUrl = "https://myserver/myapp/LEADTOOLS/LEADTOOLS.lic.txt"; 
lt.RasterSupport.setLicenseUri(licenseUrl, null, function (setLicenseResult) { 
   // Check the status of the license 
   if (setLicenseResult.result) { 
      console.log("LEADTOOLS client license set successfully"); 
      // Start using LEADTOOLS 
      var imageViewer = new lt.Controls.ImageViewer(); 
      // etc. 
   } else { 
      var msg = "LEADTOOLS License is missing, invalid or expired\nError:\n"; 
      // Add the message provided by LEADTOOLS for more information. 
      msg += result.message; 
      console.log(msg); 
      alert(msg); 
      // Exit the application 
      exitTheApp(); 
   } 
}); 

Method 2

By creating a folder on the server hosting the application and copying only LEADTOOLS.lic.txt into it:

Parameter Value
licenseUri https://myserver/myapp/LEADTOOLS/LEADTOOLS.lic.txt
developerKey The content of the LEADTOOLS.lic.key.txt file

Example

var licenseUrl = "https://myserver/myapp/LEADTOOLS/LEADTOOLS.lic.txt"; 
var developerKey = "YourDeveloperKey"; 
lt.RasterSupport.setLicenseUri(licenseUrl, developerKey, function (setLicenseResult) { 
   // Check the status of the license 
   if (setLicenseResult.result) { 
      console.log("LEADTOOLS client license set successfully"); 
      // Start using LEADTOOLS 
      var imageViewer = new lt.Controls.ImageViewer(); 
      // etc. 
   } else { 
      var msg = "LEADTOOLS License is missing, invalid or expired\nError:\n"; 
      // Add the message provided by LEADTOOLS for more information. 
      msg += result.message; 
      console.log(msg); 
      alert(msg); 
      // Exit the application 
      exitTheApp(); 
   } 
}); 

Method 3

By creating a folder on the server hosting the application and copy LEADTOOLS.lic.txt and LEADTOOLS.lic.key.txt into it. Then ensuring that the value of RasterSupport.licenseDirectory points to the correct folder:

// Set the full path 
RasterSupport.licenseDirectory = "https://myserver/myapp/LEADTOOLS"; 
// Or just the relative folder name if the application is running under myapp. This is the default value: 
RasterSupport.licenseDirectory = "LEADTOOLS"; 

Parameter Value
licenseUri null since LEADTOOLS will automatically find the license file in the correct folder
developerKey null since LEADTOOLS will automatically find the developer key file in the correct folder

Example

lt.RasterSupport.setLicenseUri(null, null, function (setLicenseResult) { 
   // Check the status of the license 
   if (setLicenseResult.result) { 
      console.log("LEADTOOLS client license set successfully"); 
      // Start using LEADTOOLS 
      var imageViewer = new lt.Controls.ImageViewer(); 
      // etc. 
   } else { 
      var msg = "LEADTOOLS License is missing, invalid or expired\nError:\n"; 
      // Add the message provided by LEADTOOLS for more information. 
      msg += result.message; 
      console.log(msg); 
      alert(msg); 
      // Exit the application 
      exitTheApp(); 
   } 
}); 

Method 4

Similar to method 3, after creating the folder, copying the files and ensuring that RasterSupport.licenseDirectory points to the correct folder, RasterSupport.setLicenseUri is optional in this case and LEADTOOLS will automatically read and try to set the license upon application startup.

Example

// Start using LEADTOOLS 
var imageViewer = new lt.Controls.ImageViewer(); 
// etc. 

setLicenseUri is the primary method used for setting the license text. In the majority of cases, it is easiest for an application to include the license text in a file to be hosted with the LEADTOOLS JavaScript SDK scripts. setLicenseUri will make a GET request for this file resource (and optionally, the developer key), then setLicenseText will be called internally to verify the license text.

A callback may be passed as the third parameter to be executed whenever the license is checked, in case the application needs to wait on the result of the license check before continuing.

The callback contains a single parameter of type SetLicenseUriResult. Upon completion, the members of this parameter will be as follows:

Member Value
result true if the license was set successfully; otherwise, false.
message If result is false, then this member contains a helpful message from LEADTOOLS describing the error that occurred.

setLicenseText and setLicenseBuffer try to set a license and block the application until completion. On errors, exceptions will be thrown with the error information.

setLicenseUri performs HTTP GET and while the request is in-flight, it will temporarily allow the application to use LEADTOOLS functionality until completion. If the license was set correctly, the application can continue. If errors occur, LEADTOOLS is locked again and will stop functioning. setLicenseUri waits for RasterSupport.requestTimeout milliseconds before terminating the request.

Important: licenseUri can reference any resource inside or outside the app. For instance, the app may be at https://appserver/myapp/app.js and the license URI can still be at https://myserver/myapp/LEADTOOLS/LEADTOOLS.lic.txt. Since setLicenseUri uses standard HTTP GET through XMLHttpRequest, it is the user's responsibility to handle accessibility and security settings. The machine and browser settings including CORS, firewalls and/or ad blockers must have the necessary permissions to allow a JavaScript application hosted on appserver to access a resource hosted on myserver.

In order to obtain a runtime license and developer key, you must contact LEAD. For more information, refer to About LEADTOOLS Runtime Licenses.

For information about LEADTOOLS Document/Medical capabilities, contact LEAD.

To determine if support for optional features has been unlocked, use rasterSupport.isLocked.

To set the runtime license from a text string, use RasterSupport.setLicenseText and to set the license from a memory buffer, use RasterSupport.setLicenseBuffer.

NOTE: As an alternative to calling setLicense, you can specify your runtime license in a folder on the server holding the application. Refer to RasterSupport.licenseDirectory for more information.

Help Version 21.0.2021.6.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.