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

Getting Started With PDFOne .NET's New PDF Web Viewer Control for ASP.NET Web Forms

Display PDF documents in ASP.NET WebForms applications.

In the latest Version 6 of PDFOne .NET, we have introduced a PDF web viewer control. It can be used in your WebForms applications to display and print PDF documents.

To display a PDF document in a Web Forms application, you need to create an instance of Web.PDFViewer control and then call the LoadDocument method. Let's get started with it:

  1. Open Visual Studio.
  2. Create an empty ASP.NET Web Application project.
  3. Open the Web.config file of the project and add the following line sin the system.web closing tag.
    <httpHandlers>
      <add verb="GET,POST" path="PDFViewer.axd" 
           type="Gnostice.PDFOne.Controls.Web.PDFViewer, Gnostice.PDFOne.Controls.Web" />
    </httpHandlers>
    <httpRuntime executionTimeout="110" maxRequestLength="901196" />
    
  4. Add this system.webServer below the system.web tag.
    <system.webServer>
     <validation validateIntegratedModeConfiguration="false" />
     <handlers accessPolicy="Read, Write, Script, Execute">
      <remove name="SPImage" />
      <add name="SPImage" verb="GET,POST" path="PDFViewer.axd" 
           type="Gnostice.PDFOne.Controls.Web.PDFViewer, Gnostice.PDFOne.Controls.Web"  />
     </handlers>
    </system.webServer>
    

  5. In Solution Explorer, add a reference to the following DLLs:
    1. Gnostice.PDFOne.Controls.Web.dll
    2. Gnostice.PDFOne.dll
    3. Gnostice.XtremeFontEngine.dll
    4. Gnostice.XtremeImageEngine.dll
  6. Select these DLLs and set their "Copy Local" property to true to ensure that your Web application is self-contained.
  7. In the Solution Explorer, right-click the project and choose to add an "App_Data" folder.
  8. Copy a PDF file named sample_doc.pdf in the App_Data folder.
  9. Add a new Web Form to the project.
  10. Add the jQuery plugin to the HEAD section in the HTML source.
  11. Switch to the Design view.
  12. Open the Toolbox and navigate to the PDFOne tab. If it is not already there, create a new one with the Gnostice.PDFOne.Controls.Web.dll.
  13. From the AJAX Extensions tab, drag and drop a ScriptManager component to the form.
  14. Drag and drop a Web.PDFViewer control on the form. Resize it to suit your requirements.
  15. Right-click on the form and select "View Code".
  16. Set the "page load" event handler as follows (but with the correct license key).
    PDFViewer1.ActiveLicense("your-license-key");
    PDFViewer1.LoadDocument(Server.MapPath(".") + "\\App_Data\\sample.pdf");
    
  17. Save the project and run it. The PDF document will be displayed in the web page.

Of course, this is a barebones example meant only to get you started. The installation setup installs a more elaborate source code example in your "Documents" folder. Please check those demos to learn more about the viewer control.

Video Demo

---o0O0o---

Our .NET Developer Tools
XtremeDocumentStudio .NET

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

PDFOne .NET

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
XtremeDocumentStudio 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
XtremeDocumentStudio (for 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
StarDocs

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

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