The Documents Library JavaScript support is included in a Visual Studio solution with source code that is located in your machine at this location:
[LEADTOOLS_INSTALLATION]\Examples\JS\Documents\DocumentViewer\DocumentViewer.sln
The solution contains multiple client-side projects with HTML, CSS, and JavaScript user interface code. These projects should run on any HTML5-supported desktop or mobile web browser. Both a Microsoft TypeScript version and compiled JavaScript version is included for each client. Full source code is included and can be modified to suit your application needs.
The remaining project, DocumentsService
, is an ASP.NET Web API application project that serves as the server-side code for the previously-mentioned clients. It can be run on a Windows machine, and a separate DocumentsServiceJava
can be run on Windows or Linux machines. With either service, all endpoints are configured to the ~/api/*
directory.
Leadtools.Documents.js
serves as the JavaScript proxy for the .NET Documents Library classes. This proxy hides the web service implementation and exposes the Documents Library as a native JavaScript library containing classes and objects. Your application should use these classes to interact with the server code.
To start using the DocumentViewer, simply open DocumentViewer.sln
in Visual Studio, select the startup projects (the client and server projects to run) and hit F5. This will run the document viewer using IIS Express, which is most suitable for development. You can set breakpoints in the client JavaScript code or in the server C# code as needed.
At any time, you can right click the project in Solution Explorer and select Deploy to host the application in IIS on the same machine, a separate machine or in the cloud. Refer to this article in MSDN for more information.
During development or deployment, you may want to modify local.config
(or the parent web.config
) to update the server side options such as the cache directory, OCR engine type or Raster Codecs options if needed.
The DocumentFactory class contains the following properties that are need for setting up the client to access the server code:
Member | Value |
---|---|
ServiceHost |
The URL to the service host. The default value is null, which means to use the same host as the client (for example, |
ServicePath |
The path from the host to the application root. The default value is null, which means to use the path to the client. By default, the project is set up such that api endpoints directory ( |
ServiceApiPath |
The path to the api endpoints of the service. The default value is null As explained above, the project is set up such that api endpoints directory ( |
ServiceUri |
Gets the full URL of the service, concatenating ServiceHost (or the client host if null), ServicePath (or the client path if null), and ServiceApiPath. This means that if no values are set, ServiceUri will be the full path to the client; if we change the ServiceApiPath to |
The JavaScript application that uses the LEADTOOLS Documents library must set the values in DocumentFactory at the beginning of the program if required. These values are global and can be accessed from any part of the application. The various classes, objects and commands of the JavaScript proxies will use these values when needed to make calls to the web service and obtain results. For example, you can start using the LoadFromUri to create a new Document object from a URL and start using it in your application.
Loading Documents Using LEADTOOLS Documents Library
Creating Documents with LEADTOOLS Documents Library
Uploading Using the Documents Library
Documents Library Coordinate System
Loading Encrypted Files Using the Documents Library
Parsing Text with the Documents Library
Barcode processing with the Documents Library
Using jQuery Promises in the Documents Library