Skip to end of metadata
Go to start of metadata
Contents Summary

This article refers to those common properties, methods, and utilities which are used in all GroupDocs.Viewer for .NET examples.

Applying License

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.


Since 19.4, the support for ViewerConfig.FontDirectories setting to vector image formats is added.

Configure ViewerConfig Class via App.config or Web.config File

This feature is supported from version 17.1.0.

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:

  1. Add <section> element into <configSections> inside <configuration> section, with the name "groupdocs.viewer" and type "GroupDocs.Viewer.Config.GroupDocsViewerSection, GroupDocs.Viewer".
  2. Add <groupdocs.viewer> section inside <configuration> section.
  3. 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.
  4. 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.
  5. Initialize ViewerConfig object using parameterless constructor.


Please note that configuration files are using camel case (lower camel case), so section names, element names and key names should obey this rule. Therefore, element name for the StoragePath property of ViewerConfig class should be storage path.

Please also note that in the app.config or web.config file, <configSections> must be the first thing to appear in the <configuration> section, otherwise an error will be thrown at runtime.

Specifying Default Font Name

This feature is supported starting from version 3.6.0 for Words and Cells documents.

This feature is supported starting from version 3.7.0 for Diagram documents.

This feature is supported starting from version 16.11.0 for Email documents.

Since version 18.1, DefaultFontName property has been moved to ImageOptions, HtmlOptions, DocumentInfoOptions and PdfFileOptions classes.


The API also allows the user to set default font name in configurations. Default font name may be specified in following cases.

  1. 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.
  2. 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.


Output Handling

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:

  1. GroupDocs.Viewer.Config
  2. GroupDocs.Viewer.Converter.Options
  3. GroupDocs.Viewer.Domain
  4. GroupDocs.Viewer.Domain.Options
  5. GroupDocs.Viewer.Handler


  • No labels