[go: up one dir, main page]

0% found this document useful (0 votes)
30 views16 pages

Integration Guide

This document provides an integration guide for using the Doconut document viewer with various web frameworks including ASP.NET, ASP.NET MVC, ASP.NET Core, and Blazor. It discusses setting up the DLL references, configuring the document handler in web.config, initializing the viewer in code, and considerations for deployment in web farms or cloud environments. Setup involves adding references, copying the license file, and configuring the handler, controller, and viewer initialization as appropriate for each framework.

Uploaded by

Hưng Phan Trung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views16 pages

Integration Guide

This document provides an integration guide for using the Doconut document viewer with various web frameworks including ASP.NET, ASP.NET MVC, ASP.NET Core, and Blazor. It discusses setting up the DLL references, configuring the document handler in web.config, initializing the viewer in code, and considerations for deployment in web farms or cloud environments. Setup involves adding references, copying the license file, and configuring the handler, controller, and viewer initialization as appropriate for each framework.

Uploaded by

Hưng Phan Trung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

www.doconut.

com

Integration Guide
February 2023

Copyright 2022 www.doconut.com


Contents
Trial Version ................................................................................................... 1
License File ................................................................................................ 2
Asp.Net ......................................................................................................... 3
DLL Reference ........................................................................................... 3
Viewer Setup.............................................................................................. 3
Document Handler ..................................................................................... 4
Client JavaScript API .................................................................................. 6
Bootstrap CSS ............................................................................................ 7
Web.Config ................................................................................................ 7
WebFarm ................................................................................................... 7
Asp.Net MVC ................................................................................................. 8
Controller ................................................................................................... 8
Reference................................................................................................... 9
Init ............................................................................................................. 9
OpenFile .................................................................................................. 10
Asp.Net Core ............................................................................................... 10
References And Nuget ............................................................................. 10
Startup.cs ................................................................................................. 11
WebFarm .................................................................................................. 11
Cloud ....................................................................................................... 12
Blazor ....................................................................................................... 13
Deployment and IIS....................................................................................... 13
IIS and Application Pool............................................................................ 14
Documentation ............................................................................................ 14

Trial Version
Once you download the zip files please right click on the zip file, open
properties window and unblock the zip. Then extract it.
If you just see an unblock checkbox, then check it and click OK.

Once you extract the zip file you will see following folders inside it.

The sample solutions (projects) do not have the required DLLs referenced.
Hence you need to either copy them to bin folder or once you open the
solution from Visual Studio, browse add reference to them.

License File

Next you will need to copy the “Doconut.lic” file from License folder to the
“bin” folder of your solution. You can specify a custom license path in
web.config using <add key="DoconutLicensePath" value="~/Licenses" /> .For
.Net Core keep it in “wwwroot” folder. The license works for “localhost”. There
is also a license for Microsoft Azure “azurewebsites.net” provided inside the
License folder.
This is a fully functional trial for 60 days. Trial version shows watermarks on
the document. Professional and Distribution license allows you to embed the
license information in the code itself.

If you want to test your application on a stating or test server then please
email us the URL and we will issue a trial license for that server.

Asp.Net
DLL Reference

Before running or compiling the visual studio solution, please ensure that you
have added reference to DocumentViewer.dll, DocumentFormats.dll and
DocumentConfig.dll. Secondly the Doconut.lic license file should be copied to
“bin” folder.

Viewer Setup

Doconut viewer has a very flexible UI. All menus, function calls are external to
the viewer. The viewer has just the thumbnail view on left and main view on
right. You can also hide/show thumbnails as required. Please refer Doconut
Manual PDF for more details.

This example is as per the “Viewer.aspx” sample page in Asp.Net sample


solution.

The viewer has 100% width and 100% height by default. Thus it takes up the
dimensions of the enclosing parent element.
As shown in this image, divDocViewer DIV element encloses the DocViewer
control. There is a css class defined on the page for divDocViewer as shown
below:

This takes care of the viewer’s width. You can change the width property as
required. For height, it is set via JavaScript. This also helps in making the
viewer responsive as the browser resizes or rotates.

You can adjust the height value as required by your page. Please refer
Viewer.aspx sample for further details.

Document Handler

For Asp.Net and Asp.Net MVC one important step in setting up the viewer is
defining the handler in web.config. Please refer sample solution’s web.config
and copy the DocImage.axd handler to your web.config. Depending upon your
IIS version you will either need System.Web or System.WebServer section. In
most modern scenarios it is System.WebServer.
This setting differs when using WebFarm scenario. It is explained in the
WebFarm section below. If you face any issue while deploying your website in
production, then please set the BasePath property of the control. More details
in the deployment section.

When using Cloud option the handler declaration will change. Following
example shows how to use the Amazon S3 handler.

Following are the available cloud provider handlers:

 AmazonS3ImageHandler
 AzureStorageImageHandler
 GoogleCloudImageHandler
 RedisImageHandler
 DropBoxImageHandler
 FTPImageHandler
 CDNImageHandler

Listed below are the web.config settings for various providers. These are used
as a fall-back if incase the settings are not available from the code. Consider
this declaration as optional.
You can add the cloud config to webserver cache or save it to disk. Please use
the Application_Start event in Global.asax.

Client JavaScript API

The API calls like Zoom, Navigation etc. are called on the client side JavaScript
instance of the Document Viewer. The object here is objDoc.
Bootstrap CSS

When using the viewer with bootstrap, you will need following class defined
on your page. It will prevent the viewer’s main view from shrinking.

Web.Config

Following two settings are used for restrictinng document viewing by


unwanted clients. Only the current user is able to view it.

Specify true for DoconutUnSafeMode and then anyone can view. In webfarm
mode as session is not available, IP address is used to retrict it.

DoconutShowInfo flag is used to show doconut viewer information, when the


DocImage.axd url is opened up in browser without any query string
parameters.

WebFarm

The default mode for Document Viewer is using Asp.Net Cache, hence the
single asp.net process memory. However you can use the viewer form a
shared file system and have multiple worker processes. For more details
please review samples related to WebFarm.

You will need an additional update in web.config. Specify the handler as


DiskImage handler as shown below:
IIS 7 or above use below in System.webServer

Next, you will need to define an app setting value for DoconutPngExportPath
as shown below. This is used by the sample code in webfarm.aspx

You may also use a shared path instead of using a path inside the web
directory. Apart from this there are two additional settings that govern the
wait time for loading a page from disk.

Page wait time seconds: The handler will wait for so many seconds while the
page file is still not available.
Start wait from page: The above code will be valid from page number higher
than the value mentioned here.

For .NET Core WebFarm set-up please refer .NET core section below.

Asp.Net MVC
MVC sample uses the same three DLLs and Doconut.lic license file as used by
the Asp.Net project. All of the above sections for Asp.Net are applicable.
However the way the viewer and its required scripts render differs for MVC.

Please refer the Simple MVC Viewer sample solution.

Controller

The index action of the home controller creates an instance of document


viewer and sets all the necessary properties.
It then stores the reference Scripts, CSS, and JavaScript initializer in ViewBag.
This is later rendered and used in the razor view.

It then stores the reference Scripts, Css, and JavaScript initializer in ViewBag.
This is later rendered and used in the razor view.

Reference

Init
OpenFile

OpenFile action is called from the client side script. This creates an instance of
“DocViewer” but here it is just to get back a valid token for the document
being viewed. This token is then used from the view as follows.

Asp.Net Core
Asp.Net core project uses .Net Standard 2.0 compiled DLLs. Works with .Net
Core 3.1, 5.0, Blazor, Razor pages. The .Net Core MVC sample is very similar to
the Asp.Net MVC sample; hence few previous sections for MVC do apply here.

References And Nuget

Please reference the three DLLs provided in the .Net Core trial zip. You will
need to add following two Nugets; Newtonsoft.Json and specific SkiaSharp
version (2.80.3).
For Linux / Docker you need additional nugets as shown below:

Newtonsoft.Json, SkiaSharp (2.80.3),,


SkiaSharp.NativeAssets.Linux.NoDependencies (2.80.3),
System.Drawing.Common, System.Text.Encoding.CodePages.

Startup.cs

In the “ConfigureServices” section, define following:

AddHttpContextAccessor is required for licensing and AddMemoryCache for


storing document objects.

In the “Configure” section, define the mapping for Doconut handler.

WebFarm

Enabling webfarm (multiple worker process) scenario in .NET Core is pretty


easy. Just change the middleware used in startup.cs
Here the webfarm is a folder in wwwroot. However ideally it should be a
central shared path that each load server should have read and write access.

Then add following code in OpenDocument action of HomeController.cs

Cloud

Just change the middleware used in startup.cs

For more details of the options used, please refer the Doconut Manual or refer
the Cloud samples.

Then add following code in OpenDocument action of HomeController.cs. This


will upload your current document to the selected cloud provider.
Following are the Nuget packages required.

Blazor

Blazor Server apps use ASP.NET Core SignalR to communicate with the
browser. Hence in order to use IhttpContextAccessor it is required that
WebSockets is enable on the server. Please refer this article:

https://docs.microsoft.com/en-
us/aspnet/core/fundamentals/websockets?view=aspnetcore-3.1#enabling-
websockets-on-iis

If you get any license error while deploying the blazor sample then please
email support.

Deployment and IIS


The deployment is very simple. It is just a matter of publishing and copying the
published code to your IIS website. However please ensure that Doconut.lic is
deployed to bin directory or you may choose to embed the license information
in code itself.

Also ensure that the Doconut handler is present in the web.config. For .Net
Core version ensure that the middleware is added to application start.
While testing your live or test website never use Internet Explorer running
from the server itself (windows server 2012, 2016, 2019 or higher). As IE runs in
high security mode and will block many portions of the viewer. Instead always
check from a client PC. Use latest version of IE/Edge or Chrome, Firefox.

If you receive an Init error while viewing then there are two possibilities 1)
Handler is not defined in the web.config 2) Your DocImage.axd path is
different. For this please set the BasePath property of the control to match
your website’s correct DocImage.axd url. Please refer a dedicated
documentation for this inside Docs folder.

IIS and Application Pool

Your IIS application pool should be configured with single worker process. If
you require a multiple worker / webfarm scenario then please refer the
WebFarm samples and modify the DocImage handler in web.config
accordingly.

Apart from these there are few other application pool settings that can be
useful in production. Open IIS > Your Application Pool > Right Click > Open
Advance Settings.

General > Queue Length 7,500 to 10,000


> Start Mode AlwaysRunning

CPU > Limit Percent 70 to 90


> Limit Action KillW3wp

Process Model > Idle Time-out 0


> Max worker process 0 (if higher, refer WebFarm)

Recycling > Private Memory Limit Set as per your server capacity

Documentation
Please refer Doconut Manual/PDF inside the Documentation folder inside the
trial zip. For any further assistance please email admin@doconut.com or visit
https://doconut.com/Document-Viewer/Faq.aspx

You might also like