In This Topic
Tutorials / ASP.NET Web Forms / Your first DocuVieware ASP.NET Web Forms page

Your first DocuVieware ASP.NET Web Forms page

In This Topic
 Overview

This tutorial will show you how to integrate DocuVieware™ in a newly created C# ASP.NET Web Forms project.

DocuVieware™ requires .NET Framework 4.6 or above.
The screenshots have been taken using Visual Studio 2015 and GdPicture.NET™ 14, it may differ from the current release.
 Empty project creation

Start with the File > New > Project... menu, then choose Web > ASP.NET Web Application. In this tutorial you will be working on DocuViewareDemo which is new ASP.NET 4.5 Web Forms project.

Depending on your Visual Studio version, you may not already have a Global.asax file in your project. In that case you want to add it too. This is also done through the Add > New item... menu, then select Global Application Class in the list.

Here is the structure obtained:

Now that the project structure is complete, the next step will be to add project references.

 Adding mandatory referencies

The references you need to add are:

  • GdPicture.NET.14.WEB.DocuVieware.dll found in [INSTALLATION FOLDER]\Redist\DocuVieware (.NET Framework 4.6)\
  • System.Web.Http from the Microsoft ASP.NET Web API

You may not have the mandatory System.Web.Http namespace directly available on your system, this is because it requires Microsoft ASP.NET Web API to be installed first.

To do this, simply run the following command in the Package Manager Console (from the Tools menu, select NuGet Package Manager and then click Package Manager Console):

PM> Install-Package Microsoft.AspNet.WebApi

       

You might also need to add Newtonsoft JSON, even though it should be already in the references but the version is outdated and it will most probably cause an error at runtime.

To do this, still in the Package Manager Console (from the Tools menu, select NuGet Package Manager and then click Package Manager Console), run the following command:

PM> Install-Package Newtonsoft.JSON

The project references should look like this:

At this point, please make sure that the GdPicture.NET.14.Web.DocuVieware reference is marked as Copy Local : True in its properties window: https://msdn.microsoft.com/library/t1zz5y8c(v=vs.100).aspx

You also need to take care of extra libraries that are mandatory for deployment, those files are found in [INSTALLATION FOLDER]\Redist\

  • GdPicture.NET.14.filters.dll (for a 32-bit execution)
  • GdPicture.NET.14.filters.64.dll (for a 64-bit execution)
  • GdPicture.NET.14.image.gdimgplug.dll (for a 32-bit execution)
  • GdPicture.NET.14.image.gdimgplug.64.dll (for a 64-bit execution)
  • GdPicture.NET.14.Imaging.Rendering.Skia.dll (for a 32-bit execution)
  • GdPicture.NET.14.Imaging.Rendering.Skia.64.dll (for a 64-bit execution)
  • GdPicture.NET.14.jbig2.encoder.dll (for a 32-bit execution)
  • GdPicture.NET.14.jbig2.encoder.64.dll (for a 64-bit execution)

They need to be added to the project (using the Add > Existing item... menu) and once done, the "Build Action" property should be set to "Content" and the "Copy to Output Directory" property should set to "Copy always" for each file.

 Licensing and configuring

Now that the references are properly set, you need to go into Global.asax.cs, add the mandatory import and handle the licensing part and the configuration part of DocuVieware™ as well.

You can find the sample source code available here: [INSTALLATION FOLDER]\Samples\ASP.NET\DocuVieware\aspnet-webform_app\Global.asax.cs

Here is the mandatory import you need to add. 

Importing the dll.
Copy Code
using GdPicture14.WEB;
Importing the dll.
Copy Code
Imports GdPicture14.WEB

To properly unlock DocuVieware™ you are going to add a call to the RegisterKEY() method in the Application_Start event.  Then please enter your license key in the method.

Unlocking the DocuVieware™.
Copy Code
DocuViewareLicensing.RegisterKEY("XXXX"); // Unlocking DocuVieware
// You need to replace "XXXX" by your actual license key.
Unlocking the DocuVieware™.
Copy Code
DocuViewareLicensing.RegisterKEY("XXXX") ' Unlocking DocuVieware
' You need to replace "XXXX" by your actual license key.

To set up the configuration of DocuVieware™ you are going to add a call to the DocuViewareManager.SetupConfiguration() method in the Application_Start event. At this point you need to create a new folder in the project that will be used for cache, for the sake of clarity simply name it Cache.

Configuring the DocuVieware™.
Copy Code
DocuViewareManager.SetupConfiguration(true, DocuViewareSessionStateMode.InProc, HttpRuntime.AppDomainAppPath + "\\Cache");
Configuring the DocuVieware™.
Copy Code
DocuViewareManager.SetupConfiguration(true, DocuViewareSessionStateMode.InProc, HttpRuntime.AppDomainAppPath + "\\Cache")

Here is what the two files should look like at this point:

You can find the sample source code available here: [INSTALLATION FOLDER]\Samples\ASP.NET\DocuVieware\aspnet-webform_app\Global.asax.cs
 DocuVieware integration

Step 1: Add the assembly registration to the page so you can add a DocuVieware™ control on it. Here is the ASP.NET code you need to add to do this:

Adding the assembly registration.
Copy Code
<%@ Register Assembly="GdPicture.NET.14.WEB.DocuVieware" Namespace="GdPicture14.WEB" TagPrefix="cc1" %>

Step 2: Add and set the DocuVieware1 object properties in the Default.aspx page, after some clean-up, like this:

Adding and setting the DocuVieware1 object properties.
Copy Code
<cc1:DocuVieware ID="DocuVieware1" runat="server" Height="800px" Width="1000px" />

DocuVieware™ will now have a fixed size of 1000x800 pixels.

Here is how the page source code looks like in the end:

That’s it! You can start the project and load documents in your brand new DocuVieware™.