Rendering Archive Files

The archive files are used to compress files to save space on disk or compress files to group them. There are different compression algorithms are used to compress files that’s why we have different archive formats. The most popular archive formats are ZIP and TAR and it’s highly likely that you’ve already packed and unpacked archive files.

Demo

Please check our online Archive Viewer Demo.

Supported Archive Formats

The following archive formats are supported by the GroupDocs.Viewer for Java.

Auto Detection means that GroupDocs.Viewer can determine the type of the archive file by reading the information in the file header.

File ExtensionFile TypeAuto Detection
.ZIPArchive file formatYes
.TARConsolidated Unix File ArchiveYes
.BZ2Bzip2 compressed fileYes
.GZGnu Zipped FileYes
.RARRoshal ARchive FileYes

Note: to get actual information about supported formats it is recommended to call getSupportedFileTypes() method of FileType class

How to render archive files

Render archive files to multiple pages HTML

To convert archive files to multiple pages HTML with GroupDocs.Viewer for Java use following code:

    try (Viewer viewer = new Viewer("sample.zip")) {
       HtmlViewOptions options = HtmlViewOptions.forEmbeddedResources("output_page_{0}.html");

       viewer.View(options);
    }

The following screenshot shows the output HTML file opened in a browser.

Multiple pages HTML converted archive

Render archive files to single HTML

To convert archive files to single page HTML with GroupDocs.Viewer for Java use following code:

    try (Viewer viewer = new Viewer("sample.zip")) {
       HtmlViewOptions options = HtmlViewOptions.forEmbeddedResources("output.html");
       options.setRenderSinglePage(true);
       viewer.view(options);
    }

The following screenshot shows the output HTML file opened in a browser.

Single page HTML converted zip

Render archive files to JPG

To convert archive files to JPG with GroupDocs.Viewer for Java use following code:

    try (Viewer viewer = new Viewer("sample.zip")) {
       JpgViewOptions options = new JpgViewOptions("output_page_{0}.jpg");
       viewer.view(options);
    }

The following screenshot shows the output JPG file opened in a Windows Photo Viewer application.

JPEG converted archive

Render archive files to PNG

To convert archive files to PNG with GroupDocs.Viewer for Java use following code:

    try (Viewer viewer = new Viewer("sample.zip")) {
       PngViewOptions options = new PngViewOptions("output_page_{0}.png");
       viewer.view(options);
    }

The following screenshot shows the output PNG file opened in a Windows Photo Viewer application.

PNG converted archive

Render archive to PDF

To convert Roshal Archive files to PDF with GroupDocs.Viewer for Java use following code:

    try (Viewer viewer = new Viewer("sample.zip")) {
       PdfViewOptions options = new PdfViewOptions("output.pdf");
       viewer.view(options);
    }

The following screenshot shows the output PDF file opened in an Acrobat Reader.

PDF converted archive

Articles in this section

The articles given in this section describes the usage of GroupDocs.Viewer to convert archive formats with different available options.

© Aspose Pty Ltd 2001-2022. All Rights Reserved.