Applying License from File
The product license sets by calling the SetLicense method of License class. Pass the license file path as a parameter in SetLicense.
Applying Metered License
As an alternative of apply license from a file, you may also set Metered license.
Getting Metered License Consumption
You can also get the consumption quantity of the metered license as follows.
The ViewerConfig class is responsible for setting the configurations of the viewer. The physical paths of the document storage, temp folder, cache folder, and the locales can be set by using this class.
Configure ViewerConfig Class via App.config or Web.config File
Public properties of ViewerConfig class can be configurated via app.config or web.config files, depending on the type of application. To configure ViewerConfig class public properties you will have to follow this steps:
- Add <section> element into <configSections> inside <configuration> section, with the name "groupdocs.viewer" and type "GroupDocs.Viewer.Config.GroupDocsViewerSection, GroupDocs.Viewer".
- Add <groupdocs.viewer> section inside <configuration> section.
- For each public property, which you want to be set, add an element inside <groupdocs.viewer> section, with the name equal to the property name and required value attribute.
- If you want to add font directory to FontDirectories collection property, create <fontDirectories> section inside <groupdocs.viewer> and append an <add> configuration element with the required path attribute for each font directory.
- Initialize ViewerConfig object using parameterless constructor.
Specifying Default Font Name
The API also allows the user to set default font name in configurations. Default font name may be specified in following cases.
- The user wants to generally specify the default font to fall back on if a particular font in a document cannot be found during rendering.
- The document uses a font that contains non-English characters and the user wants to make sure that any missing font is replaced with one which has the same character set available.
Following code snippet shows how to set default font name in configurations.
Saving Output as HTML Pages
The HTML output can be saved by using the WriteAllText method of System.IO.File. It accepts the file name and HTML contents as the parameters.
Saving Output as Images
The stream of the images can be saved to the disk by using the Save method of System.Drawing.Image.
Saving Output in a General Way
FileStream can write the file of any format to the disk by using Write method. It accepts byte array along with the range of bytes to save. Bytes can be read by using Read method of Stream which actually holds the file data.
Complete Utility Class
Utility Class consists of all common methods and properties used in the examples project. The required GroupDocs.Viewer API references are: