Multi-Format Document Viewer for ASP.NET Sites

This project is created based on the GroupDocs.Viewer for .NET library. It helps you quickly discover the library's functionality and build a custom ASP.NET document viewer capable of displaying over 50 types of documents and images, including PDF, Microsoft Word, Excel, PowerPoint, Visio, CAD and TIFF.

Please note: this project is built based on the GroupDocs.Viewer for .NET library which is not free. In order to setup and run the project, you will need to download the GroupDocs.Viewer for .NET library (a free evaluation available) from this page. If you want to test the viewer without any evaluation restrictions, please feel free to contact GroupDocs support for a free 30-day license.

Key Features of the Viewer

1. Client-Server Architecture

GroupDocs.Viewer for .NET is a lightweight .NET library designed as a client-server middleware that can be integrated into any ASP.NET website. Unlike commonly used client middleware (built based on Adobe Flash, Microsoft Silverlight, Java applet or other similar technologies), GroupDocs.Viewer for .NET doesn’t download original documents to the client-side. Instead, the library converts documents to a combination of HTML, CSS, SVG and raster images on the server and then transfers these to the client-side. When building an ASP.NET document viewer, such architecture provides you with the following benefits:

First, you avoid potential security flaws, as the original documents are not downloaded to the client during viewing sessions – they are just rendered in a browser. In other words, you can securely share your important documents, while keeping them protected from unauthorized use.

The second benefit combines cross-platform compatibility and ease of deployment. Since documents are converted to pure HTML, CSS and images, they can be viewed on any device that has a web-browser with support for HTML/CSS/JavaScript. These could be IE, Chrome, FireFox, Safari, Opera, etc. as well as their mobile versions. You don’t need to install and maintain any 3rd party software on the client-side – no need for Microsoft Office, Adobe Acrobat Reader, Flash or any browser plugins.

2. Support for 50+ File Formats

Using a single GroupDocs.Viewer for .NET library, you can build a multi-format ASP.NET document viewer capable to display all common types of business documents and images, including:

  • Portable Document Format: PDF
  • Microsoft Word: DOC, DOCX, DOCM, DOT, DOTX, DOTM
  • Microsoft Excel: XLS, XLSX, XLSM, XLSB, XML
  • Microsoft PowerPoint: PPT, PPTX, PPS, PPSX
  • Microsoft Visio: VSD, VDX, VSS, VSX, VST, VTX, VSDX, VDW
  • Microsoft Project: MPP, MPT
  • Microsoft Outlook: MSG, EML, EMLX, MHT
  • OpenDocument Formats: ODT, OTT, ODS, ODP
  • Rich Text Format: RTF
  • Plain Text File: TXT
  • Comma-Separated Values: CSV
  • HyperText Markup Language: HTML, MHT, MHTML
  • XML Paper Specification: XPS
  • AutoCAD Drawing File Format: DXF, DWG (2004)
  • Image files: BMP, GIF, JPG, PNG, TIFF, multi-page TIFF
  • Electronic publication: EPUB

3. Two Rendering Modes

The library allows you to switch between two document rendering modes: image- and HTML-based.

The image-based mode rasterizes documents to images and sends them to the client. If there is text in the original document, the library extracts it and then renders it in a separate layer on top of the rasterized backgrounds. This mode guarantees 100% accuracy, as documents are simply rasterized and texts are placed exactly where it should be using its initial coordinates from the original file.

However, the main drawback with this method is that when rasterizing large plain documents, such as Microsoft Excel sheets, large plain TXT documents or Outlook messages, the library has to split them into pages forcibly. This behavior is similar to printing such documents, when they are split in order to fit a specified paper size. Without doing so, a rasterized document may be huge and require a lot of RAM and bandwidth to render it on the client-side.

The second, HTML-based rendering mode, converts documents to pure HTML, CSS and scalable SVG images. As a result, documents are much lighter compared to rasterized ones and are not split into pages, but rendered as is. Unfortunately, some old web-browsers don’t support SVG graphics (for example, IE8 and earlier). If this is the case, you can configure GroupDocs.Viewer to replace SVG with PNG images.

Below is a screenshot of a sample XLSX document rendered in the image-based mode. Note how it is split into several pages (you can see them in the thumbnails panel):

Excel document – Image-based rendering mode

Now, the same XLSX document rendered in the HTML-based mode. It is not split into pages, but displayed as is. Also there is a tabbed navigation bar available in this mode allowing users to switch between the Excel sheets that the document contain:

Excel document – HTML-based rendering mode

4. On-Demand Page Loading and Document Caching

For faster performance, GroupDocs.Viewer adds commonly requested documents to cache. In case a document has been modified on the server, the viewer reloads the cache automatically. There is also an AOT (ahead-of-time) cashing option that allows you to forcibly add a specified document to cache, even before it is requested by users.

Another feature aimed to improve the viewer’s performance and reliability is on-demand page loading. By default, the viewer doesn’t upload an entire document to the browser, but transmits only those pages which were requested by the client at the moment.

5. Out-of-the-Box Web UI

The library comes with a web UI that can be fully customized and embed to your ASP.NET app. The UI provides the controls necessary for convenient viewing and navigation of large multi-page documents in a browser. When viewing documents through the UI, end-users can:

  • Preview and navigate document pages with thumbnails.
  • Scroll or turn pages like slides.
  • Search for text within documents using keywords.
  • Rotate, zoom in/out of a document or fit it to screen’s width/height.
  • Zoom out of the document to see all pages as tiles.
  • Select and copy text to the clipboard.
  • Re-arrange pages’ order in the document.
  • Download the original document.
  • Save the document in the PDF format.
  • Print the document right from a browser.

Please note that any of these controls, including document downloading, printing and text coping, can be easily restricted or removed at all, depending on your requirements.

Project Overview

As already stated before, this sample project aims to demonstrate the basic functionality of an ASP.NET document viewer built based on the GroupDocs.Viewer for .NET library. You can open this sample in Microsoft Visual Studio 2012 or higher. In order to run the project, you will also need to download the GroupDocs.Viewer for .NET library itself (Groupdocs.Viewer.dll) and place it into the “GroupDocsViewerWebFormsSample\libs” folder. Please use this link to download a free evaluation of the library.

Once this is done, compile and run the project. If everything was done right, you should see a start page (Default.aspx) with a set of documents in your browser.

The sample has a sort of repository (the FileRepository class) that looks into the “App_Data” folder and returns a list of documents located there. The list is displayed on the start page. We’ve included several sample documents to the “App_Data” folder. They are: “candy.pdf” and “Sample_2SpreadSheet.xlsx”. You can also add your own documents to the repository and they too will be listed on the start page.

ASP.NET document viewer – Start Page

When clicking the Open hyperlink next to a document name, a new page is opened with the document displayed within the GroupDocs.Viewer UI.

System Requirements

There is no need to install anything on the client side. The only requirement is to have a standard web-browser that supports HTML, CSS and JavaScript.

Requirements for the server side are following:

  • .NET Framework version 4.0 or higher.
  • ASP.NET WebForms or ASP.NET MVC version 3 or higher.
  • IIS, IIS Express or ASP.NET Development Server (Cassini).

Please note that the GroupDocs.Viewer for .NET library is not free. In order to setup and run the project, you will need to download the GroupDocs.Viewer for .NET library (a free evaluation available) from this page. You can also get a free 30 trial license by contacting the GroupDocs sales. I’d strongly recommend you to do so, as the license allows you to test the viewer without any functional limitations.

For more details on how you can use the library to build an ASP.NET document viewer, as well as for complete documentation and support/sales contacts, please visit GroupDocs website at:
http://groupdocs.com/dot-net/document-viewer-library

Last edited Sep 16, 2015 at 11:42 AM by GroupDocs, version 15