# Render archives as HTML, PDF, and image files Convert archive files (ZIP, RAR, etc.) to HTML, PDF, PNG, or JPEG using GroupDocs.Viewer for Python. [GroupDocs.Viewer for Python via .Net](https://products.groupdocs.com/viewer/python-net) allows you to view the contents of archive files in HTML, PDF, PNG, and JPEG formats. You do not need to use third-party file archiver and compression software to display archive file contents within your .NET application (web or desktop). To start using the GroupDocs.Viewer API, create a [Viewer](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer) class instance. Pass an archive file you want to view to the class constructor. You can load the archive from a file or stream. Call one of the [Viewer.view](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method overloads to convert the archive file to HTML, PDF, or image format. {{< button style="primary" link="https://products.groupdocs.app/viewer/archive" >}} {{< icon "gdoc_person" >}} View archive files online {{< /button >}} {{< button style="primary" link="https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET" >}} {{< icon "gdoc_github" >}} View demos and examples on GitHub {{< /button >}} ## Supported archive and compressed file formats GroupDocs.Viewer supports the following archive file formats: * [.7Z (7-Zip Compressed File)](https://docs.fileformat.com/compression/7z) * [.BZ2 (Bzip2 Compressed File)](https://docs.fileformat.com/compression/bz2) * [.GZ (Gnu Zipped Archive)](https://docs.fileformat.com/compression/gz) * [.RAR (WinRAR Compressed Archive)](https://docs.fileformat.com/compression/rar) * [.TAR (Consolidated Unix File Archive)](https://docs.fileformat.com/compression/tar) * [.TGZ / .TAR.GZ (Gzipped Tar File)](https://docs.fileformat.com/compression/tgz/) * [.TXZ / .TAR.XZ (XZ Compressed Tar Archive)](https://docs.fileformat.com/compression/xz/) * [.XZ (XZ Compressed Archive)](https://docs.fileformat.com/compression/xz/) * [.ZIP (Zipped File)](https://docs.fileformat.com/compression/zip) GroupDocs.Viewer can detect the archive file format automatically based on information in the file header. ## Render archive files as HTML To convert an archive file to HTML, call the [HtmlViewOptions.for_embedded_resources](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/htmlviewoptions/#methods) method to create an [HtmlViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/htmlviewoptions) class instance and pass this instance to the [Viewer.view](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method. {{< tabs "example1">}} {{< tab "Python" >}} ```python from groupdocs.viewer import Viewer from groupdocs.viewer.options import HtmlViewOptions def render_archive_to_html(): # Load archive file with Viewer("documents.zip") as viewer: # Create an HTML file for the top folder and each subfolder in the archive. # {0} is replaced with the current page number in the output file name. viewOptions = HtmlViewOptions.for_embedded_resources("render_archive_to_html/pdf_page_{0}.html") viewer.view(viewOptions) if __name__ == "__main__": render_archive_to_html() ``` {{< /tab >}} {{< tab "documents.zip" >}} {{< tab-text >}} `documents.zip` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/python-net/_sample_files/rendering-basics/render-archive-files/documents.zip) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "pdf_page_1.html" >}} ```text HTML file (73 KB) ``` [Download full output](https://docs.groupdocs.com/viewer/python-net/_output_files/rendering-basics/render-archive-files/render_archive_to_html/pdf_page_1.html) {{< /tab >}} {{< /tabs >}} ### Create a single HTML page If you need to display the contents of an archive file on a single HTML page, enable the [HtmlViewOptions.render_to_single_page](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/htmlviewoptions/#properties) option, as shown below: {{< tabs "example3">}} {{< tab "Python" >}} ```python from groupdocs.viewer import Viewer from groupdocs.viewer.options import HtmlViewOptions def render_archive_to_single_html(): # Load archive file with Viewer("documents.zip") as viewer: # Create an HTML file. viewOptions = HtmlViewOptions.for_embedded_resources("render_archive_to_single_html/archive_to_single_html.html") # Render the archive file to a single page. viewOptions.render_to_single_page = True viewer.view(viewOptions) if __name__ == "__main__": render_archive_to_single_html() ``` {{< /tab >}} {{< tab "documents.zip" >}} {{< tab-text >}} `documents.zip` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/python-net/_sample_files/rendering-basics/render-archive-files/documents.zip) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "archive_to_single_html.html" >}} ```text HTML file (73 KB) ``` [Download full output](https://docs.groupdocs.com/viewer/python-net/_output_files/rendering-basics/render-archive-files/render_archive_to_single_html/archive_to_single_html.html) {{< /tab >}} {{< /tabs >}} You can navigate between the archive folders. Click on a particular folder to see its contents. To go backward, click the required folder name in the navigation bar at the top of the web page. ## Render archive files as PDF Create a [PdfViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfviewoptions) class instance and pass it to the [Viewer.view](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method to convert an archive file to PDF. The `PdfViewOptions` class properties allow you to control the conversion process. For instance, you can protect the output PDF file or reorder its pages. Refer to the following documentation section for details: [Rendering to PDF]({{< ref "viewer/python-net/developer-guide/rendering-documents/rendering-to-pdf/_index.md" >}}). {{< tabs "example4">}} {{< tab "Python" >}} ```python from groupdocs.viewer import Viewer from groupdocs.viewer.options import PdfViewOptions def render_archive_to_pdf(): # Load archive file with Viewer("documents.zip") as viewer: # Create a PDF file. viewOptions = PdfViewOptions("render_archive_to_pdf/archive_content.pdf") viewer.view(viewOptions) if __name__ == "__main__": render_archive_to_pdf() ``` {{< /tab >}} {{< tab "documents.zip" >}} {{< tab-text >}} `documents.zip` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/python-net/_sample_files/rendering-basics/render-archive-files/documents.zip) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "archive_content.pdf" >}} ```text Binary file (PDF, 81 KB) ``` [Download full output](https://docs.groupdocs.com/viewer/python-net/_output_files/rendering-basics/render-archive-files/render_archive_to_pdf/archive_content.pdf) {{< /tab >}} {{< /tabs >}} ## Render archive files as PNG Create a [PngViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pngviewoptions) class instance and pass it to the [Viewer.view](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method to convert an archive file to PNG. Use the [PngViewOptions.height](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pngviewoptions/#properties) and [PngViewOptions.width](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pngviewoptions/#properties) properties to specify the output image size in pixels. {{< tabs "example5">}} {{< tab "Python" >}} ```python from groupdocs.viewer import Viewer from groupdocs.viewer.options import PngViewOptions def render_archive_to_png(): # Load archive file with Viewer("documents.zip") as viewer: # Create a PNG image for the top folder and each subfolder in the archive. # {0} is replaced with the current page number in the image name. viewOptions = PngViewOptions("render_archive_to_png/archive_page_0_{0}.png") # Set width and height. viewOptions.width = 800 viewOptions.height = 1000 viewer.view(viewOptions) if __name__ == "__main__": render_archive_to_png() ``` {{< /tab >}} {{< tab "documents.zip" >}} {{< tab-text >}} `documents.zip` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/python-net/_sample_files/rendering-basics/render-archive-files/documents.zip) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "archive_page_0_1.png" >}} ```text Binary file (PNG, 104 KB) ``` [Download full output](https://docs.groupdocs.com/viewer/python-net/_output_files/rendering-basics/render-archive-files/render_archive_to_png/archive_page_0_1.png) {{< /tab >}} {{< /tabs >}} ## Render archive files as JPEG Create a [JpgViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/jpgviewoptions) class instance and pass it to the [Viewer.view](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer/viewer/#methods) method to convert an archive file to JPEG. Use the [JpgViewOptions.height](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/jpgviewoptions/#properties) and [JpgViewOptions.width](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/jpgviewoptions/#properties) properties to specify the output image size in pixels. {{< tabs "example6">}} {{< tab "Python" >}} ```python from groupdocs.viewer import Viewer from groupdocs.viewer.options import JpgViewOptions def render_archive_to_jpg(): # Load archive file with Viewer("documents.zip") as viewer: # Create a JPEG image for the top folder and each subfolder in the archive. # {0} is replaced with the current page number in the image name. viewOptions = JpgViewOptions("render_archive_to_jpg/archive_to_jpg_{0}.jpg") # Set width and height. viewOptions.width = 800 viewOptions.height = 1000 viewer.view(viewOptions) if __name__ == "__main__": render_archive_to_jpg() ``` {{< /tab >}} {{< tab "documents.zip" >}} {{< tab-text >}} `documents.zip` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/python-net/_sample_files/rendering-basics/render-archive-files/documents.zip) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "archive_to_jpg_1.jpg" >}} ```text Binary file (JPG, 84 KB) ``` [Download full output](https://docs.groupdocs.com/viewer/python-net/_output_files/rendering-basics/render-archive-files/render_archive_to_jpg/archive_to_jpg_1.jpg) {{< /tab >}} {{< /tabs >}} ## Render a specific folder When you convert an archive file to HTML, PDF, or image format, GroupDocs.Viewer renders items from all folders contained in the archive. If you need to render items from a specific folder, specify the [ArchiveOptions.folder](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/archiveoptions/#properties) property for one of the following classes (depending on the output file format): * [HtmlViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/htmlviewoptions) * [PdfViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pdfviewoptions) * [PngViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/pngviewoptions) * [JpgViewOptions](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/jpgviewoptions) {{< tabs "example8">}} {{< tab "Python" >}} ```python from groupdocs.viewer import Viewer from groupdocs.viewer.options import HtmlViewOptions def render_specific_archive_folder(): # Load archive file with Viewer("documents.zip") as viewer: # Create an HTML file. viewOptions = HtmlViewOptions.for_embedded_resources("render_specific_archive_folder/specific_archive_folder.html") viewOptions.archive_options.folder = "Invoices" viewer.view(viewOptions) if __name__ == "__main__": render_specific_archive_folder() ``` {{< /tab >}} {{< tab "documents.zip" >}} {{< tab-text >}} `documents.zip` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/python-net/_sample_files/rendering-basics/render-archive-files/documents.zip) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "specific_archive_folder.html" >}} ```text HTML file (13 KB) ``` [Download full output](https://docs.groupdocs.com/viewer/python-net/_output_files/rendering-basics/render-archive-files/render_specific_archive_folder/specific_archive_folder.html) {{< /tab >}} {{< /tabs >}} ## Specify the archive file name When rendering an archive file, GroupDocs.Viewer displays the archive file name in the header of each page. If you need to change or hide this name, define the [archive_options.file_name](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/archiveoptions/#properties) property for a target view. You can set this option to one of the following values: * [FileName.SOURCE](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/filename/#properties)--- Returns the name of the source file (this name is used by default). * [FileName.EMPTY](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/filename/#properties)---Specifies an empty name. Use this value to hide the archive file name in the output file. * A [FileName](https://reference.groupdocs.com/viewer/python-net/groupdocs.viewer.options/filename/) instance with a custom name you want to display in the output file. The following code snippet demonstrates how to use a custom name when rendering an archive file to HTML: {{< tabs "example9">}} {{< tab "Python" >}} ```python from groupdocs.viewer import Viewer from groupdocs.viewer.options import HtmlViewOptions, FileName def render_archive_with_custom_filename(): # Load archive file with Viewer("documents.zip") as viewer: # Create an HTML file for the top folder and each subfolder in the archive. # {0} is replaced with the current page number in the output file name. viewOptions = HtmlViewOptions.for_embedded_resources("render_archive_with_custom_filename/archive_with_custom_filename_{0}.html") # Specify a custom filename viewOptions.archive_options.file_name = FileName("Sample Files") viewer.view(viewOptions) if __name__ == "__main__": render_archive_with_custom_filename() ``` {{< /tab >}} {{< tab "documents.zip" >}} {{< tab-text >}} `documents.zip` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/python-net/_sample_files/rendering-basics/render-archive-files/documents.zip) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "archive_with_custom_filename_1.html" >}} ```text HTML file (73 KB) ``` [Download full output](https://docs.groupdocs.com/viewer/python-net/_output_files/rendering-basics/render-archive-files/render_archive_with_custom_filename/archive_with_custom_filename_1.html) {{< /tab >}} {{< /tabs >}}