Render Archives to Single or Multiple HTML Pages
Introduction
GroupDocs.Viewer for .NET is a powerful document rendering library that allows developers to effortlessly integrate document viewing capabilities into their .NET applications. Whether you need to render archives to single or multiple HTML pages, this tutorial will guide you through the process step by step.
Prerequisites
Before diving into this tutorial, ensure you have the following prerequisites:
- GroupDocs.Viewer for .NET: Make sure you have the library installed in your project. You can download it from here.
- Development Environment: Have a working development environment set up for .NET development.
- Document Directory: Prepare a directory where your documents are stored.
- Basic Understanding of C#: Familiarize yourself with C# programming language basics.
Import Namespaces
In your C# code, make sure to import the necessary namespaces:
using GroupDocs.Viewer.Options;
using System;
using System.IO;
Follow these steps to render archives to single or multiple HTML pages using GroupDocs.Viewer for .NET:
Step 1: Set Output Directory
Define the directory where you want the rendered HTML pages to be saved:
string outputDirectory = "Your Document Directory";
Step 2: Define File Path Format
Specify the file path format for the HTML pages. For single-page rendering:
string pageFilePathFormat = Path.Combine(outputDirectory, "RAR_result.html");
For multi-page rendering:
pageFilePathFormat = Path.Combine(outputDirectory, "RAR_result_page_{0}.html");
Step 3: Render to Single Page HTML
using (Viewer viewer = new Viewer(TestFiles.SAMPLE_RAR_WITH_FOLDERS))
{
HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);
options.RenderToSinglePage = true;
viewer.View(options);
}
Step 4: Render to Multiple Pages HTML
using (Viewer viewer = new Viewer(TestFiles.SAMPLE_RAR_WITH_FOLDERS))
{
HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);
options.ArchiveOptions.ItemsPerPage = 10; // Set items per page
viewer.View(options);
}
Step 5: Check Output
Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
Conclusion
Rendering archives to HTML pages using GroupDocs.Viewer for .NET is a straightforward process. By following the steps outlined in this tutorial, you can seamlessly integrate document viewing capabilities into your .NET applications.
FAQ’s
Can I render other document formats besides archives?
Yes, GroupDocs.Viewer supports a wide range of document formats including PDF, DOCX, XLSX, PPTX, and more.
Is GroupDocs.Viewer suitable for both desktop and web applications?
Absolutely, GroupDocs.Viewer can be utilized in both desktop and web applications seamlessly.
Does GroupDocs.Viewer offer customization options for the viewer interface?
Yes, you can customize the viewer interface according to your requirements.
Can I render documents asynchronously with GroupDocs.Viewer?
Yes, GroupDocs.Viewer provides asynchronous rendering capabilities for improved performance.
Does GroupDocs.Viewer support document annotations?
Yes, GroupDocs.Viewer allows users to view and manage document annotations efficiently.