setLicense method

setLicense(licenseName)

Licenses the component.

setLicense(licenseName: string)
ParameterTypeDescription
licenseNamestringCan be a full or short file name. Use an empty string to switch to evaluation mode.

Remarks

Tries to find the license in the following locations:

  1. Explicit path.

setLicense(stream)

Licenses the component.

setLicense(stream: Buffer)
ParameterTypeDescription
streamBufferA stream that contains the license.

Remarks

Use this method to load a license from a stream.

Examples

Shows how initialize a license for Aspose.words using a license file in the local file system.

// Set the license for our Aspose.Words product by passing the local file system filename of a valid license file.
const licFilename = "Aspose.Words.NodeJs.NET.lic";
var licenseFileName =  path.join(base.licenseDir, licFilename);

let license = new aw.License();
try {
  license.setLicense(licenseFileName);

  // Create a copy of our license file in the binaries folder of our application.
  var licenseCopyFileName = path.join(base.codeBaseDir, licFilename);
  fs.copyFileSync(licenseFileName, licenseCopyFileName);

  // If we pass a file's name without a path,
  // the SetLicense will search several local file system locations for this file.
  // One of those locations will be the "bin" folder, which contains a copy of our license file.
  license.setLicense(licFilename);

Shows how to initialize a license for Aspose.words from a stream.

// Set the license for our Aspose.words product by passing a stream for a valid license file in our local file system.
let data = base.loadFileToBuffer(path.join(base.licenseDir, "Aspose.Words.NodeJs.NET.lic"));
let license = new aw.License();
license.setLicense(data);

See Also