Skip to content

Commit 4912ea7

Browse files
authored
Create mobile-web-capture.md
Add warning note re: plus edition for Mobile
1 parent e15fbd8 commit 4912ea7

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
layout: default-layout
3+
needAutoGenerateSidebar: true
4+
title: How to enable mobile capture
5+
keywords: Dynamic Web TWAIN, Documentation, Mobile Web Capture
6+
breadcrumbText: Mobile Web Capture
7+
description: Dynamic Web TWAIN SDK Documentation Mobile Web Capture Page
8+
---
9+
10+
> [!WARNING]
11+
> Mobile Web Capture has been removed from Dynamic Web TWAIN as of Release 18.2. If you still require Mobile Web Capture, you must use the Plus edition of Dynamic Web TWAIN v18.1. Please contact [support@dynamsoft.com](mailto:support@dynamsoft.com) for further details.
12+
13+
# How to Enable Mobile Web Capture
14+
15+
You can follow the steps below to use Dynamic Web TWAIN SDK to enable image capture from mobile cameras in a web page.
16+
17+
<!--- Firstly, please [download and install Dynamic Web TWAIN](https://www.dynamsoft.com/web-twain/downloads) if you haven't done so. --->
18+
19+
## Start a Web application
20+
21+
Create a `mobile-capture.html` and copy the `Resources` folder of Dynamic Web TWAIN, which can be found under the installation folder, to the same location.
22+
23+
## Include the library
24+
25+
Embed the scripts of the library, among which `dynamsoft.webtwain.addon.camera.js` is the add-on module for mobile web capture.
26+
27+
``` html
28+
<script src="Resources/dynamsoft.webtwain.initiate.js"></script>
29+
<script src="Resources/dynamsoft.webtwain.config.js"></script>
30+
<script src="Resources/addon/dynamsoft.webtwain.addon.camera.js"></script>
31+
```
32+
33+
Add an `div` element on the page for the library. `dwtcontrolContainer` is the default ID for the div. You can change it in the file `dynamsoft.webtwain.config.js` if necessary.
34+
35+
``` html
36+
<div id="dwtcontrolContainer"></div>
37+
```
38+
39+
## Add code for mobile web capture
40+
41+
The below code shows how to scan a document from scanners on desktop and invoke the camera module for mobile capture.
42+
43+
``` javascript
44+
function AcquireImage() {
45+
if (DWObject) {
46+
if (Dynamsoft.Lib.env.bMobile) {
47+
var showVideoConfigs = {
48+
scannerViewer:{
49+
autoDetect:{
50+
enableAutoDetect: true
51+
}
52+
},
53+
filterViewer: {
54+
exitDocumentScanAfterSave: true
55+
}
56+
};
57+
58+
if(!DWObject.UseLocalService) {
59+
// invoke the camera module for mobile capture
60+
DWObject.Addon.Camera.scanDocument(showVideoConfigs).then(
61+
function(){
62+
console.log("OK");
63+
},
64+
function(error){
65+
console.log(error.message);
66+
});
67+
}
68+
}
69+
else {
70+
DWObject.SelectSource(
71+
function() {
72+
DWObject.OpenSource();
73+
DWObject.AcquireImage();
74+
},
75+
function() {
76+
console.log("SelectSource failed!");
77+
});
78+
}
79+
}
80+
}
81+
```
82+
83+
## See the mobile capture page in action
84+
85+
To try out the mobile web capture, please first deploy the web application as an HTTPS site so that it will get proper authentication to access the mobile cameras.
86+
87+
## Try mobile capture demo
88+
89+
Here is a working mobile capture online demo which you can test.
90+
91+
- [Try mobile capture online demo](https://demo.dynamsoft.com/web-twain/mobile-online-camera-scanner/)
92+
- [Download mobile capture sample code](https://www.dynamsoft.com/web-twain/sample-downloads/?demoSampleId=663)
93+
94+
## Additional notes:
95+
96+
1. By default, the size of the viewer is 270 in width and 350 in height, so it'll appear to be too small. Check out [how to customize the viewer]({{site.indepth}}features/viewer.html#customize-the-viewer) for more information.
97+
98+
2. Important: Not all mobile browsers allow the use of cameras. Check out [browsers on mobile devices]({{site.getstarted}}platform.html#browsers-on-mobile-devices) for more information. If you are using an unsupported browser (for example, Chrome on iOS), you may receive the error `The current browser has not implemented the MediaDevices interface`.

0 commit comments

Comments
 (0)