This guide will help you to quickly setup and run the sample ASP.NET PDF viewer built using the GroupDocs.Viewer for .NET library.
Please note! This sample ASP.NET PDF viewer is built using the commercial library – GroupDocs.Viewer for .NET. In order to setup and run this project, you will need to download the GroupDocs.Viewer for .NET library from this page. If you’d like to test the viewer without any restrictions, please contact GroupDocs support for a free 30-day license.
In short, there is no need to download or install anything on the client side.
Unlike client-based PDF viewers, GroupDocs.Viewer for .NET doesn’t transfer original documents to end user machines. Instead, the library converts documents to web compatible content (HTML + CSS + images) on the server and then renders it in user web-browsers. Hence, there is no need to install any office software or plugins on the client side. Any modern web-browser that supports HTML/CSS/JS and SVG or raster images can render documents displayed with the viewer, including:
Download this sample package.
Download the GroupDocs.Viewer for .NET library from this page.
Open the sample in Microsoft Visual Studio 2012 or higher.
Place the downloaded GroupDocs.Viewer for .NET library (Groupdocs.Viewer.dll) into the GroupDocsViewerWebFormsSample\libs folder.
Once you compile and run the project, you should see a start page - Default.aspx. Here you can find two sample documents that we’ve included for demonstration purposes (a PDF file and a XLSX spreadsheet). There are options to view the files either in an image- or HTML-based rendering modes. The difference is that in the image-based mode the library extracts textual content, rasterizes documents and then renders extracted texts over the rasterized backgrounds. In the HTML-based rendering mode, the library converts documents to pure HTML markup, CSS and SVG (or PNG) images. You can configure the default rendering mode depending on your preferences.
The sample documents are located in the App_Data folder. You can add your own documents to the folder to open them with the viewer.
The project has a sort of repository (the FileRepository class). It browses the App_Data folder and lists files located there on the Default.aspx page. Once you’ve added a document to the App_Data folder, simply refresh the Default.aspx page to see the document in the list.
GroupDocs.Viewer sends asynchronous requests to stream documents from the server to clients. All the necessary HTTP-handlers can be found in the web.config file.
In ASP.NET MVC there is no need to set all these HTTP-handlers - you can invoke the Groupdocs.Web.UI.Viewer.InitRoutes() method instead.
A root storage path can be specified in the Application_Start method within the Global.asax file. Here you can also set a license file and specify a log file path. Without the license file, GroupDocs.Viewer works in an evaluation mode. Please feel free to contact GroupDocs support for a 30-day trial license to be able to test the viewer without any evaluation restrictions.
There is also a Viewer.aspx page containing the GUI (GroupDocs.Viewer widget). All the necessary JavaScript and CSS libraries are included to the HEAD block of the page, while the widget itself:
<%= Viewer.ClientCode().TargetElementSelector("#viewer")…
... is located in the BODY block. When the web-page is rendered, the widget transforms to a JavaScript code, which invokes GroupDocs.Viewer, creates a viewport and fills it with requested document’s content.
At the end of the Viewer.aspx page there is also a JS code responsible for the dynamic resizing of the GroupDocs.Viewer viewport.
ASP.NET PDF Viewer by GroupDocs - Features Overview:
http://groupdocs.com/blog/asp-net-pdf-viewer-built-based-on-the-groupdocs-viewer-for-net-library
GroupDocs.Viewer for .NET library – Homepage:
http://groupdocs.com/dot-net/document-viewer-library
Support Forum:
http://groupdocs.com/Community/Forums/Default.aspx