Powerful all-in-one PDF library for .NET
VS 2005/2008/2010/2012/2013

Display PDF documents in ASP.NET MVC Web applications with Gnostice PDFOne's new PDF Viewer extension

Getting started with the new AJAX-enabled MVC PDF Viewer extension.

Early last month, we released a major update to PDFOne. In this update, we had introduced a new Ajax-enabled MVC extension for displaying PDF documents. (PDFOne already has an Web Forms PDF viewer component.)

In this article, we will see how to create a simple PDF Viewer application using this new MVC extension. Here are the steps:

  1. Open Visual Studio and create a new "empty" MVC project.
  2. Add references to the following DLLs:
    • Gnostice.PDFOne.dll
    • Gnostice.PDFOne.Extensions.MVC.dll
    • Gnostice.PDFOne.dll
    • Gnostice.XtremeFontEngine.dll
    • Gnostice.XtremeImageEngine.dll
    • BouncyCastle.Crypto.dll
  3. Select these DLLs and set their "Copy Local" properties to true.
  4. Select the project and add a Global.asax ("Global Application Class") file as "a new item".
  5. In the Application_Start() method, add the following line to activate the product license. Please use trial key if you are using the trial version. If you are using the registered version, use the key that was sent to you by e-mail when made the purchase order.
  6. Gnostice.PDFOne.Extensions.MVC.PDFViewer.ActivateLicense("your-license-key");
  7. In Solution Explorer, select "Controllers" and add a new empty "Home" controller.
  8. Add a new default view for the Index() method of the controller (without any layout, model, or strongly typed view) and give it the name "Index".
  9. Select "Scripts" and add jQuery to the project.
  10. Drag and drop jQuery to the "head" section of the Index view (Index.cshtml).
  11. Enter the following directives below the jQuery script tag so that the razor engine will load the JavaScript files of the PDFOne MVC PDF viewer control when the page is displayed in a browser.
  12. In the DIV tag, enter these lines to render the PDF viewer control.
        PDFViewerSettings PDFViewerSettings1 = new PDFViewerSettings();
        PDFViewerSettings1 = new PDFViewerSettings();
        PDFViewerSettings1.Width = System.Web.UI.WebControls.Unit.Pixel(700);
        PDFViewerSettings1.Height = System.Web.UI.WebControls.Unit.Pixel(700);
        PDFViewerSettings1.ClientObjectName = "pdfviewer1";
          Server.MapPath("~/App_Data/") + "sample_doc.pdf"
  13. Add a new "App_Data" folder to the project.
  14. Copy a PDF file named "sample_doc.pdf" into the folder.
  15. Open the Web.config file and add the following line above the closing "system.web" tag.
      <add name="Gnostice.PDFOne.Extensions.MVC.PDFViewerHttpHandlerModule" 
  16. Above the closing tag of "system.webServer" tag, add the following lines.
    <modules runAllManagedModulesForAllRequests="true">
     <add type="Gnostice.PDFOne.Extensions.MVC.PDFViewerHttpHandlerModule" 
          name="PDFViewerHttpHandlerModule" >
    If there is no system.webServer tag, then add the following lines above the "runtime" tag.
      <validation validateIntegratedModeConfiguration="false" </>
       <modules runAllManagedModulesForAllRequests="true">
          <add type="Gnostice.PDFOne.Extensions.MVC.PDFViewerHttpHandlerModule" 
               name="PDFViewerHttpHandlerModule" />
  17. Build the project and then run it.


Our .NET Developer Tools
Gnostice Document Studio .NET

Multi-format document-processing component suite for .NET developers.


A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Delphi/C++Builder developer tools
Gnostice Document Studio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
Gnostice Document Studio Java

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Our Platform-Agnostic Cloud and On-Premises APIs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved.