Using Your Doconut License

To find out how to use a Doconut license, follow the instructions below for different .NET platforms.

Doconut License Installation

In this section, you will learn how to install and activate your Doconut license across various environments, including .NET Framework, .NET Standard/Core, and .NET 6. Follow the steps provided to ensure seamless integration of your license into your project:

.NET Framework

Automatic License Detection

Doconut can automatically detect licenses if they are placed within the project's bin folder.

Add Manual Default License

If you prefer to add the license manually, the following options are available:

Add License by File Path

This method uses the Viewer.DoconutLicense(string licencePath) overload to add a license by specifying the path to the license file.

var licensePath = "path/to/your/license.lic";
Viewer.DoconutLicense(licensePath);

Add License by Stream

This method uses the Viewer.DoconutLicense(Stream licenseStream) overload to add a license using a stream.

using (var licenseStream = new FileStream("path/to/your/license", FileMode.Open))
{
Viewer.DoconutLicense(licenseStream);
}

Add License by XML Document

This method uses the Viewer.DoconutLicense(XMLDocument licence) overload to add a license using an XML document.

var xmlDoc = new XmlDocument();
xmlDoc.Load("path/to/your/license.xml");
Viewer.DoconutLicense(xmlDoc);

Add Plugin License by File Path

This method uses the Viewer.SetLicensePlugin(string pathPluginLicence) overload to add a plugin license by specifying the path to the plugin license file.

var pluginLicensePath = "path/to/your/plugin-license.lic";
Viewer.SetLicensePlugin(pluginLicensePath);

Add Plugin License by Stream

This method uses the Viewer.SetLicensePlugin(Stream pluginLicence) overload to add a plugin license using a stream.

using (var pluginLicenseStream = new FileStream("path/to/your/plugin-license.lic", FileMode.Open))
{
Viewer.SetLicensePlugin(pluginLicenseStream);
}

Add Plugin License by XML Document

This method uses the Viewer.SetLicensePlugin(XMLDocument xmlPluginLicence) overload to add a plugin license using an XML document.

var pluginXmlDoc = new XmlDocument();
pluginXmlDoc.Load("path/to/your/plugin-license.xml");
Viewer.SetLicensePlugin(pluginXmlDoc);

.NET Standard/Core and .NET 6 and higher

Automatic License Detection

Doconut can automatically detect licenses if they are placed within the project's wwwroot folder.

To initialize the docViewer with automatic license detection, use the following line:

var docViewer = new Viewer(_cache, _accessor);

Add Manual Default License

You can manually specify the path to a single default license file when initializing the viewer.

var licenseFilePath = Path.Combine(_hostingEnvironment.WebRootPath, "path/to/your/license");
var docViewer = new Viewer(_cache, _accessor, licenseFilePath);

Add License by Stream

This method uses the Viewer.DoconutLicense(Stream licenseStream) overload to add a license using a stream.

using (var licenseStream = new FileStream("path/to/your/license", FileMode.Open))
{
Viewer.DoconutLicense(licenseStream);
}

Add License by XML Document

This method uses the Viewer.DoconutLicense(XMLDocument licence) overload to add a license using an XML document.

var xmlDoc = new XmlDocument();
xmlDoc.Load("path/to/your/license.xml");
Viewer.DoconutLicense(xmlDoc);

Manual Default Multiple Plugin Licenses

If you need to specify multiple licenses, you can provide a list of file paths to the viewer initialization.

List<string> licenseFilePaths = new List<string>
{
    Path.Combine(_hostingEnvironment.WebRootPath, "Doconut.Viewer.lic"),
    Path.Combine(_hostingEnvironment.WebRootPath, "Doconut.Viewer.Annotation.lic"),
    Path.Combine(_hostingEnvironment.WebRootPath, "Doconut.Viewer.Search.lic")
};
var docViewer = new Viewer(_cache, _accessor, licenseFilePaths);

Add Plugin License by Stream

This method uses the Viewer.SetLicensePlugin(Stream pluginLicence) overload to add a plugin license using a stream.

using (var pluginLicenseStream = new FileStream("path/to/your/plugin-license.lic", FileMode.Open))
{
Viewer.SetLicensePlugin(pluginLicenseStream);
}

Add Plugin License by XML Document

This method uses the Viewer.SetLicensePlugin(XMLDocument xmlPluginLicence) overload to add a plugin license using an XML document.

var pluginXmlDoc = new XmlDocument();
pluginXmlDoc.Load("path/to/your/plugin-license.xml");
Viewer.SetLicensePlugin(pluginXmlDoc);

Protecting Your License File

To safeguard your Doconut license file (.lic), it is essential to follow best practices for file security. Store the license file in a secure directory with restricted access, ensuring that only authorized users or services can read it.