com.groupdocs.viewer.handler

Class ViewerHtmlHandler

    • Constructor Detail

      • ViewerHtmlHandler

        public ViewerHtmlHandler()

        Initializes a new instance of the ViewerHtmlHandler class.

      • ViewerHtmlHandler

        public ViewerHtmlHandler(IFileStorage fileStorage)

        Initializes a new instance of the ViewerHtmlHandler class.

        Parameters:
        fileStorage - The file storage.
      • ViewerHtmlHandler

        @Deprecated
        public ViewerHtmlHandler(IFileStorage fileStorage,
                                    com.groupdocs.foundation.utils.CultureInfo cultureInfo)
        Deprecated. 

        Initializes a new instance of the ViewerHtmlHandler class.

        Deprecated:
        This constructor is obsolete and will be removed after v19.10.

        Parameters:
        fileStorage - The file storage.
        cultureInfo - The viewer culture. Supported cultures are en-Us, pt-PT and ru-RU.
      • ViewerHtmlHandler

        public ViewerHtmlHandler(ViewerConfig viewerConfig)

        Initializes a new instance of the ViewerHtmlHandler class.

        Parameters:
        viewerConfig - The viewer configuration.
      • ViewerHtmlHandler

        @Deprecated
        public ViewerHtmlHandler(ViewerConfig viewerConfig,
                                    com.groupdocs.foundation.utils.CultureInfo cultureInfo)
        Deprecated. 

        Initializes a new instance of the ViewerHtmlHandler class.

        Deprecated:
        This constructor is obsolete and will be removed after v19.10.

        Parameters:
        viewerConfig - The viewer configuration.
        cultureInfo - The viewer culture. Supported cultures are en-Us, pt-PT and ru-RU.
      • ViewerHtmlHandler

        public ViewerHtmlHandler(ViewerConfig viewerConfig,
                         IFileStorage fileStorage)

        Initializes a new instance of the ViewerHtmlHandler class.

        Parameters:
        viewerConfig - The viewer configuration.
        fileStorage - The file storage.
      • ViewerHtmlHandler

        @Deprecated
        public ViewerHtmlHandler(ViewerConfig viewerConfig,
                                    IFileStorage fileStorage,
                                    com.groupdocs.foundation.utils.CultureInfo cultureInfo)
        Deprecated. 

        Initializes a new instance of the ViewerHtmlHandler class.

        Deprecated:
        This constructor is obsolete and will be removed after v19.10.

        Parameters:
        viewerConfig - The viewer configuration.
        fileStorage - The file storage.
        cultureInfo - The viewer culture. Supported cultures are en-Us, pt-PT and ru-RU.
      • ViewerHtmlHandler

        public ViewerHtmlHandler(ViewerConfig viewerConfig,
                         IInputDataHandler inputDataHandler)

        Initializes a new instance of the ViewerHtmlHandler class.

        Parameters:
        viewerConfig - The viewer configuration.
        inputDataHandler - The input data handler.
      • ViewerHtmlHandler

        @Deprecated
        public ViewerHtmlHandler(ViewerConfig viewerConfig,
                                    IInputDataHandler inputDataHandler,
                                    com.groupdocs.foundation.utils.CultureInfo cultureInfo)
        Deprecated. 

        Initializes a new instance of the ViewerHtmlHandler class.

        Deprecated:
        This constructor is obsolete and will be removed after v19.10.

        Parameters:
        viewerConfig - The viewer configuration.
        inputDataHandler - The input data handler.
        cultureInfo - The viewer culture. Supported cultures are en-Us, pt-PT and ru-RU.
      • ViewerHtmlHandler

        public ViewerHtmlHandler(ViewerConfig viewerConfig,
                         IInputDataHandler inputDataHandler,
                         ICacheDataHandler cacheDataHandler)

        Initializes a new instance of the ViewerHtmlHandler class.

        Parameters:
        viewerConfig - The viewer configuration.
        inputDataHandler - The input data handler.
        cacheDataHandler - The cache data handler.
      • ViewerHtmlHandler

        @Deprecated
        public ViewerHtmlHandler(ViewerConfig viewerConfig,
                                    IInputDataHandler inputDataHandler,
                                    ICacheDataHandler cacheDataHandler,
                                    com.groupdocs.foundation.utils.CultureInfo cultureInfo)
        Deprecated. 

        Initializes a new instance of the ViewerHtmlHandler class.

        Deprecated:
        This constructor is obsolete and will be removed after v19.10.

        Parameters:
        viewerConfig - The viewer configuration.
        inputDataHandler - The input data handler.
        cacheDataHandler - The cache data handler.
        cultureInfo - The viewer culture. Supported cultures are en-Us, pt-PT and ru-RU.
    • Method Detail

      • getPages

        public List<PageHtml> getPages(AttachmentBase attachment)
                                throws Exception

        Get list of pages html representations for attachment.

        Note:
        NOTE

        Example:
        The following example demonstrates how to get the html representations of the attachment.

         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
         DocumentInfoContainer info = htmlHandler.getDocumentInfo("C:\storage\document-with-attachments.msg");
        
         for (AttachmentBase attachment : info.getAttachments()) {
           List<PageHtml> pages = htmlHandler.getPages(attachment);
         }
         

        Parameters:
        attachment - The attachment.
        Returns:
        The list of pages html representations.
        Throws:
        Exception
      • getPages

        public List<PageHtml> getPages(AttachmentBase attachment,
                              HtmlOptions htmlOptions)
                                throws Exception

        Get list of pages html representations for attachment.

        Example:
        The following example demonstrates how to get the html representations of the attachment.

         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
        
         DocumentInfoContainer info = htmlHandler.getDocumentInfo("C:\storage\document-with-attachments.msg");
         HtmlOptions htmlOptions = new HtmlOptions();
         htmlOptions.setEmbedResources(false);
        
         for (AttachmentBase attachment : info.getAttachments()) {
           List<PageHtml> pages = htmlHandler.getPages(attachment, htmlOptions);
         }
         

        Parameters:
        attachment - The attachment.
        htmlOptions - The HTML options.
        Returns:
        The list of pages html representations.
        Throws:
        Exception
      • getPages

        public List<PageHtml> getPages(InputStream fileStream)
                                throws Exception

        Get list of pages html representations.

        Example:
        The following example demonstrates how to get the list of pages.

         FileInputStream fileStream = new FileInputStream("document.doc");
         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
        
         List<PageHtml> pages = htmlHandler.getPages(fileStream);
         

        Parameters:
        fileStream - The file stream
        Returns:
        The list of pages html representations
        Throws:
        Exception
      • getPages

        public List<PageHtml> getPages(InputStream fileStream,
                              AttachmentBase attachment)
                                throws Exception

        Get list of pages html representations for attachment.

        Example:
        The following example demonstrates how to get the html representations of the attachment.

         FileInputStream fileStream = new FileInputStream("C:\storage\document-with-attachments.msg");
         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
        
         DocumentInfoContainer info = htmlHandler.getDocumentInfo(fileStream);
        
         for (AttachmentBase attachment : info.getAttachments()) {
           List<PageHtml> pages = htmlHandler.getPages(fileStream, attachment);
         }
         fileStream.close();
         

        Parameters:
        fileStream - The file stream.
        attachment - The attachment.
        Returns:
        The list of pages html representations.
        Throws:
        Exception
      • getPages

        public List<PageHtml> getPages(InputStream fileStream,
                              AttachmentBase attachment,
                              HtmlOptions htmlOptions)
                                throws Exception

        Get list of pages html representations for attachment.

        Example:
        The following example demonstrates how to get the html representations of the attachment.

         FileInputStream fileStream = new FileInputStream("C:\storage\document-with-attachments.msg");
         ViewerConfig config = new ViewerConfig();
         config.setEnableCaching(true);
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
        
         DocumentInfoContainer info = htmlHandler.getDocumentInfo(fileStream);
         HtmlOptions htmlOptions = new HtmlOptions();
         htmlOptions.setEmbedResources(false);
        
         for (AttachmentBase attachment : info.getAttachments()) {
           List<PageHtml> pages = htmlHandler.getPages(fileStream, attachment, htmlOptions);
         }
         

        Parameters:
        fileStream - The file stream.
        attachment - The attachment.
        htmlOptions - The HTML options.
        Returns:
        The list of pages html representations.
        Throws:
        Exception
      • getPages

        public List<PageHtml> getPages(InputStream fileStream,
                              HtmlOptions htmlOptions)
                                throws Exception

        Get list of pages html representations.

        Example:
        The following example demonstrates how to get the list of pages.

         FileInputStream fileStream = new FileInputStream("document.doc");
         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
         HtmlOptions options = new HtmlOptions();
         options.setPageNumbersToRender(new ArrayList<Integer>(Arrays.asList(1, 3));
        
         List<PageHtml> pages = htmlHandler.getPages(fileStream, options);
         

        Parameters:
        fileStream - The file stream
        htmlOptions - The HTML options
        Returns:
        The list of pages html representations
        Throws:
        Exception
      • getPages

        public List<PageHtml> getPages(InputStream fileStream,
                              String fileName)
                                throws Exception

        Get list of pages html representations.

        Example:
        The following example demonstrates how to get the list of pages.

         String fileName = "document.doc";
         FileInputStream fileStream = new FileInputStream("document.doc");
         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
        
         List<PageHtml> pages = htmlHandler.getPages(fileStream, fileName);
         

        Parameters:
        fileStream - The file stream
        fileName - The file name.
        Returns:
        The list of pages html representations
        Throws:
        Exception
      • getPages

        public List<PageHtml> getPages(InputStream fileStream,
                              String fileName,
                              HtmlOptions htmlOptions)
                                throws Exception

        Get list of pages html representations.

        Note:
        Passing file name along with the file Stream, in contract to passing just file Stream will result in reduced processing time, because file type detection operation won't be involved.

        Example:
        The following example demonstrates how to get the list of pages.

         String fileName = "document.doc";
         FileInputStream fileStream = new FileInputStream("document.doc");
         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
         HtmlOptions options = new HtmlOptions();
         options.setPageNumbersToRender(new ArrayList<Integer>(Arrays.asList(1, 3));
        
         List<PageHtml> pages = htmlHandler.getPages(fileStream, fileName, options);
         

        Parameters:
        fileStream - The file stream
        fileName - The file name.
        htmlOptions - The HTML options.
        Returns:
        The list of pages html representations
        Throws:
        Exception
      • getPages

        public List<PageHtml> getPages(String guid)
                                throws Exception

        Get list of pages html representations.

        Example:
        The following example demonstrates how to get the list of pages.

         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
         String guid = "C:\storage\document.doc";
        
         List<PageHtml> pages = htmlHandler.getPages(guid);
         

        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:
        The list of pages html representations
        Throws:
        Exception
      • getPages

        public List<PageHtml> getPages(String guid,
                              HtmlOptions htmlOptions)
                                throws Exception

        Get list of pages html representations.

        Example:
        The following example demonstrates how to get the list of pages.

         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
         HtmlOptions options = new HtmlOptions();
         options.getPageNumber(2);
         options.setCountPagesToRender(1);
         String guid = "C:\storage\document.doc";
        
         List<PageHtml> pages = htmlHandler.getPages(guid, options);
         

        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.
        htmlOptions - The HTML rendering options
        Returns:
        The list of pages html representations
        Throws:
        Exception
      • getPages

        public List<PageHtml> getPages(URI uri)
                                throws Exception

        Get list of pages html representations.

        Example:
        The following example demonstrates how to get the list of pages.

         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
         Uri uri = new Uri("http://example.com/sample.doc");
        
         List<PageHtml> pages = htmlHandler.getPages(uri);
         

        Parameters:
        uri - The Uri.
        Returns:
        The list of pages html representations
        Throws:
        Exception
      • getPages

        public List<PageHtml> getPages(URI uri,
                              HtmlOptions htmlOptions)
                                throws Exception

        Get list of pages html representations.

        Note:
        NOTE

        Example:
        The following example demonstrates how to get the html representations of the first and third pages.

         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
         HtmlOptions options = new HtmlOptions();
         options.setPageNumbersToRender(new ArrayList<Integer>(Arrays.asList(1, 3));
         Uri uri = new Uri("http://example.com/sample.doc");
         List<PageHtml> pages = htmlHandler.getPages(uri, options);
         

        Parameters:
        uri - The Uri.
        htmlOptions - The HTML options.
        Returns:
        The list of pages html representations
        Throws:
        Exception
      • getPages

        public List<PageHtml> getPages(URI uri,
                              WindowsAuthenticationCredential credential,
                              HtmlOptions htmlOptions)
                                throws Exception

        Get list of pages html representations.

        Example:
        The following example demonstrates how to get html representations of the first and third pages.

         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
        
         HtmlOptions options = new HtmlOptions();
         options.setPageNumbersToRender(new ArrayList<Integer>(Arrays.asList(1, 3));
         WindowsAuthenticationCredential credentials = new WindowsAuthenticationCredential("user", "password");
         Uri uri = new Uri("http://example.com/sample.doc");
        
         List<PageHtml> pages = htmlHandler.getPages(uri, credentials, options);
         

        Parameters:
        uri - The Uri.
        credential - The credential.
        htmlOptions - The HTML options.
        Returns:
        The list of pages html representations.
        Throws:
        Exception
      • getPrintableHtml

        public PrintableHtmlContainer getPrintableHtml(String guid)
                                                throws Exception

        Get document HTML for printing.

        Specified by:
        getPrintableHtml in class ViewerHandler<PageHtml>
        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:
        The document HTML for printing.
        Throws:
        Exception
      • getPrintableHtml

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

        Get document HTML for print.

        Example:
        The following example demonstrates how to get printable HTML of the document.

         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
         String guid = "C:\storage\document.doc";
         PrintableHtmlOptions options = new PrintableHtmlOptions(guid);
        
         PrintableHtmlContainer container = htmlHandler.getPrintableHtml(options);
         

        Specified by:
        getPrintableHtml in class ViewerHandler<PageHtml>
        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 printable HTML options.
        Returns:
        The document HTML for printing.
        Throws:
        Exception
      • getResource

        public InputStream getResource(AttachmentBase attachment,
                              HtmlResource htmlResource)
                                throws Exception

        Get html page resource stream.

        Example:
        The following example demonstrates how to get resource stream of each HtmlResource in html representation pages of the document.

         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
         EmailAttachment attachment = new EmailAttachment(@"C:\storage\document-with-attachments.msg", "attachment-image.png");
         List<PageHtml> pages = htmlHandler.getPages(attachment);
        
         for (PageHtml page : pages) {
           for (HtmlResource resource in page.getHtmlResources()) {
             InputStream resourceStream = htmlHandler.getResource(guid, resource);
             System.out.println(resourceStream.available());
           }
         }
         

        Parameters:
        attachment - The attachment descriptor.
        htmlResource - The HTML resource.
        Returns:
        Resource stream.
        Throws:
        Exception
      • getResource

        public InputStream getResource(String guid,
                              HtmlResource htmlResource)
                                throws Exception

        Get html page resource stream.

        Example:
        The following example demonstrates how to get resource stream of each HtmlResource in html representation pages of the document.

         ViewerConfig config = new ViewerConfig();
         ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
         String guid = "C:\storage\document.doc";
         List<PageHtml> pages = htmlHandler.getPages(guid);
        
         for (PageHtml page : pages) {
           for (HtmlResource resource in page.getHtmlResources()) {
             InputStream resourceStream = htmlHandler.getResource(guid, resource);
             System.out.println(resourceStream.available());
           }
         }
         

        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.
        htmlResource - The HTML resource.
        Returns:
        Resource stream.
        Throws:
        Exception