This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

mobile-web-capture
TypeScript icon, indicating that this package has built-in type declarations

18.0.3 • Public • Published

Dynamic Web TWAIN Mobile Web Capture SDK

version downloads jsdelivr

Dynamic Web TWAIN Mobile Web Capture SDK is a web document capture SDK for iOS and Android browsers. It is designed for developers to build document scanning web applications for mobile users to load, edit, save, upload files, and capture images from the camera right in mobile browsers.

To see it in action, please visit this online demo.

Note: Dynamic Web TWAIN SDK v18.0 is built in this package.

Table of Contents

Supported Environments

Supported Mobile Web Browsers

  • Chrome
  • Edge
  • Safari

Supported OSs

  • Android
  • iOS

License Key

Installation

  • Packages from the official website

    Dynamic Web TWAIN SDK

  • NPM

    npm install mobile-web-capture

Deployment

Dynamic Web TWAIN relies on the files in the /dist/ folder to work. Make sure to put these files on your server and correctly refer to them by specifying the path with ResourcesPath (relative and absolute paths are both okay).

Quick Start

Step 1. Create an HTML page and load dynamsoft.webtwain.min.js into your page:

<!DOCTYPE html>
<html>
<head>
 <title>Hello World</title>
 <script src="dist/dynamsoft.webtwain.min.js"></script>
</head>
<body>
</body>
</html>

Note that a relative path is used. You might want to change it based on where you are putting your code. The best practice is to put all the files on your own server and under the same domain as your web application.

Step 2. Add a script tag and make initial settings:

<!DOCTYPE html>
<html>
<head>
 <title>Hello World</title>
 <script src="dist/dynamsoft.webtwain.min.js"></script>
</head>
<body>
 <script type="text/javascript">
   //Dynamsoft.DWT.ProductKey = "YOUR-PRODUCT-KEY";  // Put your own key here
   Dynamsoft.DWT.ResourcesPath = "dist";
   Dynamsoft.DWT.Containers = [{ ContainerId: 'dwtcontrolContainer', Width: 270, Height: 350 }];
   Dynamsoft.DWT.UseLocalService = false;
 </script>
</body>
</html>

Note that ResourcesPath must be set in order to use the library.

  1. ResourcesPath is a relative path to where you put the directory "/dist/" and all the files in it.
  2. If you don't have a valid ProductKey, you can request a trial key to use.
  3. To better use the mobile web capture, the UseLocalService must be set to false.

Step 3. Write code to use the package to do a simple document scan

The following code demonstrates the minimum code needed to use the package. Note the addition of HTML elements as well as JavaScript code. For more sophisticated sample or demo, check out our Github Repositories.

<!DOCTYPE html>
<html>
<head>
 <title>Hello World</title>
 <script src="dist/dynamsoft.webtwain.min.js"></script>
</head>
<body>
 <input type="button" value="Scan" onclick="ScanDocument();" />
 <div id="dwtcontrolContainer"></div>
 <script type="text/javascript">
   //Dynamsoft.DWT.ProductKey = "YOUR-PRODUCT-KEY";  // Put your own key here
   Dynamsoft.DWT.ResourcesPath = "dist";
   Dynamsoft.DWT.Containers = [{ ContainerId: 'dwtcontrolContainer', Width: 370, Height: 450 }];
   Dynamsoft.DWT.UseLocalService = false;
   window.onload = function () {
     Dynamsoft.DWT.Load();
   };
   var DWObject;
   function Dynamsoft_OnReady() {
     // dwtcontrolContainer is the id of the DIV to create the WebTwain instance in.
     DWObject = Dynamsoft.DWT.GetWebTwain('dwtcontrolContainer');
   }
   function ScanDocument() {
     var showVideoConfigs = {
       scannerViewer:{
         autoDetect:{
           enableAutoDetect: true
         }
       }
     };
     if (DWObject) {
       if(!DWObject.UseLocalService) {
         DWObject.Addon.Camera.scanDocument(showVideoConfigs).then(
           function(){
             console.log("Successful!");
           }, function (error) { 
             alert(error.message); 
           }); 
       }
     }
   }
 </script>
</body>
</html>

Step 4. Configure the Server

  • Set the MIME type for .wasm as application/wasm on your webserver.

    The goal is to configure your server to send the correct Content-Type header for the wasm file so that it is processed correctly by the browser.

    Different types of webservers are configured differently, for example:

    • Apache
    • IIS
    • NGINX
  • Enable HTTPS

    To use the library, you must access your website / web application via a secure HTTPS connection. This is due to browser security restrictions which only grant camera video streaming access to a secure context.

For convenience, self-signed certificates can be used during development and testing.

Documentation

Features

Features Mobile
Document capture ✔️
Document edge detection ✔️
Document perspective correction ✔️
Document post-processing by filters ✔️
Front and rear camera switching ✔️
Dedicated image and PDF viewer ✔️
Built-in ready-to-use UI ✔️
SIMD and WebGL acceleration ✔️
Multi-Format export and sharing ✔️

More

Contact Us

Contact Dynamsoft to resolve any issue you encounter with the library.

License Agreement

https://www.dynamsoft.com/Products/WebTWAIN_License.aspx

Changelog

Check out the release notes of the Dynamic Web TWAIN library.

Package Sidebar

Install

npm i mobile-web-capture

Weekly Downloads

19

Version

18.0.3

License

SEE LICENSE IN LICENSE.txt

Unpacked Size

38.2 MB

Total Files

58

Last publish

Collaborators

  • ellie-dynamsoft