com.groupdocs.viewer.config

Class ViewerConfig

  • All Implemented Interfaces:
    Cloneable


    public class ViewerConfig
    extends Object
    implements Cloneable

    Provides methods to configure Viewer handler.

    • Constructor Detail

      • ViewerConfig

        public ViewerConfig()

        Initializes a new instance of the ViewerConfig class.

    • Method Detail

      • getFontDirectories

        public List<String> getFontDirectories()
        The custom font directories paths
        Returns:
        the custom font directories paths
      • setCacheFolderName

        public void setCacheFolderName(String value)

        The name of the folder inside the storage path that will be used for storing cache files.

        Note:
        This property is ignored when CachePath property is set.

        Example:
        The following example demonstrates how to set cache folder name. As the cache path has not been set, cache will be stored inside the 'C:\storage\cachefolder\'.

         ViewerConfig config = new ViewerConfig();
         config.setStoragePath("C:\storage");
         config.setCacheFolderName("cachefolder");
         

        Parameters:
        value - The cache folder name.
      • setCachePath

        public void setCachePath(String value)

        The path to the directory, where the cache will be stored.

        Note:
        When the cache path is set, the cache folder name will be ignored.

        Example:
        The following example demonstrates how to set the cache path.

         ViewerConfig config = new ViewerConfig();
         config.setCachePath("C:\cachefolder\");
         

        Parameters:
        value - The cache path
      • setEnableCaching

        public void setEnableCaching(boolean value)

        Indicates whether to cache rendering results or not.

        Note:
        Enabling cache will let to avoid processing the same document more than once

        Example:
        The following example demonstrates how to enable caching.

         ViewerConfig config = new ViewerConfig();
         config.setEnableCaching(true);
         

        Parameters:
        value - true if enable caching; otherwise, false
      • setFontDirectories

        public void setFontDirectories(List<String> value)
        Sets the custom font directories paths
        Parameters:
        value - new custom font directories paths
      • setForcePasswordValidation

        public void setForcePasswordValidation(boolean value)

        Indicates whether to force password validation for protected documents. By default is false.

        Note:
        When the password protected document is rendered with the caching enabled, the password is not validated on subsequent calls. Set this option true, when you need to force checking password each time the document is rendered. Please note, that the password validation increases rendering time.

        Example:
        The following example demonstrates how to force password validation.

         ViewerConfig config = new ViewerConfig();
         config.setStoragePath("C:\storage\");
         config.setEnableCaching(true);
         config.setForcePasswordValidation(true);
        
         ViewerImageHandler imageHandler = new ViewerImageHandler(config);
         String guid = "document.docx";
         List<PageImage> pages = imageHandler.getPages(guid);
         

        Parameters:
        value - true if enable; otherwise, false
      • setLocalesPath

        @Deprecated
        public void setLocalesPath(String value)
        Deprecated. 

        The path to locales.

        Note:
        Locales (xml files with localized strings) if present, will be loaded from locales path directory. Files inside this directory should have the following naming convention: "LocalizedStrings-{Language Culture Name}.xml" where {Language Culture Name} is your culture name e.g. "fr-FR". To learn more press here

        Example:
        The following example demonstrates how to set locales path

         ViewerConfig config = new ViewerConfig();
         config.setLocalesPath("D:\Locales");
         

        Deprecated:
        This property is obsolete and will be removed after v19.2.

        Parameters:
        value - The locales path
      • setPageNamePrefix

        public void setPageNamePrefix(String value)

        The prefix for generated page name. Default is "page".

        Note:
        The page name prefix is used for naming files in the cache. It should not contain invalid characters, that are not allowed for file names.

        Example:
        The following example demonstrates how to set the page name prefix.

         ViewerConfig config = new ViewerConfig();
         config.setPageNamePrefix("mypageprefix");
         

        Parameters:
        value - The page name prefix.
      • setStoragePath

        public void setStoragePath(String value)

        The path to the documents storage directory.

        Note:
        Storage path acts as a base location in the file system, for the documents rendering. When the full path to the document is not provided, API assumes that the document is located in the storage directory. By default, cache files are stored in the folder, inside the storage directory.

        Example:
        The following example demonstrates how to set the storage path and render document located inside the storage directory.

         ViewerConfig config = new ViewerConfig();
         config.setStoragePath("C:\storage");
        
         ViewerImageHandler imageHandler = new ViewerImageHandler(config);
         string guid = "document.docx";
         List<PageImage> pages = imageHandler.getPages(guid);
         

        Parameters:
        value - The storage path.