Render RAR Archives

Introduction

RAR archives are a popular format for compressing and storing multiple files and folders into a single container. Rendering RAR archives into various formats such as HTML, JPG, PNG, or PDF can be essential for viewing or sharing the contents of these archives. In this tutorial, we will explore how to render RAR archives using GroupDocs.Viewer for .NET.

Prerequisites

Before we begin, ensure that you have the following prerequisites:

  1. GroupDocs.Viewer for .NET: Install GroupDocs.Viewer for .NET library from the download link.
  2. Sample RAR Archive: Have a sample RAR archive ready for rendering.

Import Namespaces

using GroupDocs.Viewer.Options;
using GroupDocs.Viewer.Results;
using System;
using System.IO;

Step 1: Define Output Directory

string outputDirectory = "Your Document Directory";

Step 2: Render to HTML

string pageFilePathFormat = Path.Combine(outputDirectory, "RAR_result_{0}.html");
using (Viewer viewer = new Viewer("YourRarFile.rar"))
{
    HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);
    viewer.View(options);
}

Step 3: Render to JPG

string pageFilePathFormat = Path.Combine(outputDirectory, "RAR_result_{0}.jpg");
using (Viewer viewer = new Viewer("YourRarFile.rar"))
{
    JpgViewOptions options = new JpgViewOptions(pageFilePathFormat);
    viewer.View(options);
}

Step 4: Render to PNG

string pageFilePathFormat = Path.Combine(outputDirectory, "RAR_result_{0}.png");
using (Viewer viewer = new Viewer("YourRarFile.rar"))
{
    PngViewOptions options = new PngViewOptions(pageFilePathFormat);
    viewer.View(options);
}

Step 5: Render to PDF

string pageFilePathFormat = Path.Combine(outputDirectory, "RAR_result.pdf");
using (Viewer viewer = new Viewer("YourRarFile.rar"))
{
    PdfViewOptions options = new PdfViewOptions(pageFilePathFormat);
    viewer.View(options);
}

Conclusion

Rendering RAR archives into various formats is made simple with GroupDocs.Viewer for .NET. By following the steps outlined in this tutorial, you can effortlessly convert RAR archives to HTML, JPG, PNG, or PDF formats, enabling easy viewing and sharing of their contents.

FAQ’s

Can GroupDocs.Viewer for .NET handle encrypted RAR archives?

Yes, GroupDocs.Viewer for .NET supports rendering encrypted RAR archives provided that the necessary passwords are provided during the rendering process.

Is it possible to customize the output appearance of rendered documents?

Absolutely! GroupDocs.Viewer for .NET offers extensive customization options allowing users to tailor the appearance of rendered documents according to their preferences.

Does GroupDocs.Viewer for .NET support rendering other archive formats apart from RAR?

Yes, GroupDocs.Viewer for .NET supports rendering various archive formats including ZIP, TAR, 7z, and more.

Can I integrate GroupDocs.Viewer for .NET into my web application?

Certainly! GroupDocs.Viewer for .NET provides APIs that are suitable for integration into both desktop and web applications.

Is there a trial version available for GroupDocs.Viewer for .NET?

Yes, you can avail of a free trial of GroupDocs.Viewer for .NET from the website.