com.groupdocs.viewer.handler

Class ViewerHandler<T extends Page>

    • Field Detail

      • viewerConfig

        protected final ViewerConfig viewerConfig

        The viewer configuration.

      • inputDataHandler

        protected final IInputDataHandler inputDataHandler

        The input data handler.

      • cacheDataHandler

        protected final ICacheDataHandler cacheDataHandler

        The cache data handler.

      • localizationHandler

        protected final ILocalizationHandler localizationHandler

        The localization handler.

    • Method Detail

      • clearCache

        public void clearCache()
                        throws Exception

        Clears all files from cache.


         The following example demonstrates how to clear all files from cache.
         
         ViewerConfig config = new ViewerConfig();
         config.setUseCache(true);
         config.setCachePath( "C:\\storage\\cachefiles\\");
         ViewerImageHandler imageHandler = new ViewerImageHandler(config);
         String guid = "C:\\storage\\document.doc";
         java.util.List imagePages = imageHandler.GetPages(guid);
         imageHandler.clearCache();
         

        Throws:
        Exception
      • clearCache

        public void clearCache(long olderThan)
                        throws Exception

        Clears files from cache older than specified time interval.

        Parameters:
        olderThan - The time interval.
        Throws:
        Exception
      • getSupportedDocumentFormats

        public DocumentFormatsContainer getSupportedDocumentFormats()

        Gets supported document formats.


         The following example demonstrates how to get the list of supported document formats.
         
         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
         DocumentFormatsContainer supportedFormats = htmlHandler.getSupportedDocumentFormats();
         

      • getDocumentInfo

        public DocumentInfoContainer getDocumentInfo(String guid)
                                              throws Exception

        Gets the document information.


         The following example demonstrates how to get document information.
         
         ViewerConfig config = new ViewerConfig();
         ViewerImageHandler imageHandler = new ViewerImageHandler(config);
         String guid = "C:\\storage\\aspose-logo.jpg";
         DocumentInfoContainer documentInfo = imageHandler.getDocumentInfo(guid);
         
        Throws:
        Exception
      • getDocumentInfo

        public DocumentInfoContainer getDocumentInfo(String guid,
                                            DocumentInfoOptions documentInfoOptions)
                                              throws Exception

        Gets the document information.


         The following example demonstrates how to get document information.
         
         ViewerConfig config = new ViewerConfig();
         ViewerImageHandler imageHandler = new ViewerImageHandler(config);
         String guid = "C:\\storage\\aspose-logo.jpg";
         DocumentInfoContainer documentInfo = imageHandler.getDocumentInfo(guid);
         
        Throws:
        Exception
      • getFile

        public FileContainer getFile(String guid)

        Get original file.


         The following example demonstrates how to get original file.
         
         ViewerConfig config = new ViewerConfig();
         ViewerImageHandler imageHandler = new ViewerImageHandler(config);
         String guid = "C:\\storage\\aspose-logo.jpg";
         FileContainer container = imageHandler.getFile(guid);
         

      • getFileList

        public FileListContainer getFileList()

        Retrieves list of files and directories for root storage path.

      • getPages

        protected List<T> getPages(String guid,
                       RenderOptions renderOptions)
                                         throws Exception

        Get list of pages representations.

        Parameters:
        guid - The file unique identifier, full path for local storage e.g. c:\\storage\\document.txt, relative path e.g document.txt, url e.g. http://site.com/document.txt.
        renderOptions - The render options.
        Returns:
        List of converted pages
        Throws:
        Exception
      • getPages

        protected List<T> getPages(InputStream fileStream,
                       RenderOptions renderOptions)
                                         throws Exception

        Get list of pages HTML representations.

        Parameters:
        fileStream - The file stream.
        renderOptions - The render options.
        Returns:
        List of converted pages
        Throws:
        Exception
      • getPages

        protected List<T> getPages(InputStream fileStream,
                       String fileName,
                       RenderOptions renderOptions)
                                         throws Exception

        Get list of pages representations.

        Parameters:
        fileStream - The file stream.
        fileName - The file name.
        renderOptions - The render options.
        Returns:
        List of converted pages
        Throws:
        Exception
      • getPages

        protected List<T> getPages(URI uri,
                       RenderOptions renderOptions)
                                         throws Exception

        Get list of pages representations from URI.

        Parameters:
        uri - The URI.
        renderOptions - The render options.
        Returns:
        List of converted pages
        Throws:
        Exception
      • getPages

        protected List<T> getPages(AttachmentBase attachment,
                       RenderOptions renderOptions)
                                         throws Exception

        Get list of pages representations from URI with credentials.

        Parameters:
        attachment - The attachment descriptor.
        renderOptions - The render options.
        Returns:
        List of converted pages.
        Throws:
        Exception
      • getPdfFile

        public FileContainer getPdfFile(String guid)
                                 throws Exception

        Gets the PDF file.


         The following example demonstrates how to render document as PDF.
         
         ViewerConfig config = new ViewerConfig();
         ViewerImageHandler imageHandler = new ViewerImageHandler(config);
         String guid = "C:\\storage\\document.doc";
         FileContainer container = imageHandler.getPdfFile(guid);
         //use container.Stream to manipulate pdf representation of the input file.
         

        Throws:
        Exception
      • getPdfFile

        public FileContainer getPdfFile(String guid,
                               PdfFileOptions pdfFileOptions)
                                 throws Exception

        Gets the PDF file.


         The following example demonstrates how to render document as PDF.
         
         ViewerConfig config = new ViewerConfig();
         ViewerImageHandler imageHandler = new ViewerImageHandler(config);
         String guid = "C:\\storage\\document.doc";
         FileContainer container = imageHandler.getFile(guid);
         

        Throws:
        Exception
      • getPrintableHtml

        public abstract PrintableHtmlContainer getPrintableHtml(String guid,
                                              PrintableHtmlOptions printableHtmlOptions)
                                                         throws Exception

        Get document HTML for print.

        Parameters:
        guid - The file unique identifier, full path for local storage e.g. c:\\storage\\document.txt, relative path e.g document.txt, url e.g. http://site.com/document.txt
        printableHtmlOptions - The rotatePageOptions.
        Returns:
        PrintableHtmlContainer.
        Throws:
        Exception
      • getPrintableHtml

        public abstract PrintableHtmlContainer getPrintableHtml(String guid)
                                                         throws Exception

        Get document HTML for print.

        Parameters:
        guid - The file unique identifier, full path for local storage e.g. c:\\storage\\document.txt, relative path e.g document.txt, url e.g. http://site.com/document.txt
        Returns:
        PrintableHtmlContainer.
        Throws:
        Exception
      • loadFileTree

        @Deprecated
        public FileTreeContainer loadFileTree()
        Deprecated. 

        Loads files/folders structure for specified path.

        Returns:
        FileTreeContainer for detailed information.
      • loadFileTree

        @Deprecated
        public FileTreeContainer loadFileTree(FileTreeOptions fileTreeOptions)
        Deprecated. 

        Loads files/folders structure for specified path.

        Parameters:
        fileTreeOptions - FileTreeOptions for detailed information.
        Returns:
        FileTreeContainer for detailed information.
      • getViewerConfig

        protected ViewerConfig getViewerConfig()