Skip to content

Commit efc9f94

Browse files
authored
Merge pull request #663 from dynamsoft-docs/preview
Preview
2 parents 25e506d + f1a5759 commit efc9f94

File tree

10 files changed

+498
-18
lines changed

10 files changed

+498
-18
lines changed

_data/full_tree.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ tree_list:
5151
path: /indepth/development/react.html
5252
- name: Use Web TWAIN in Vue
5353
path: /indepth/development/vue.html
54+
# - name: Use Web TWAIN in Vue 3
55+
# path: /indepth/development/vue3.html
5456
- name: Simple Demo
5557
path: https://www.dynamsoft.com/web-twain/resources/code-gallery/
5658
- name: API Reference

faq/difference-between-Twain-and-wia.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ permalink: /faq/difference-between-Twain-and-wia.html
1111

1212
# Capture/Image Source
1313

14-
## What are the differences between TWAIN and WIA?
14+
## What are the differences between TWAIN and WIA drivers?
1515

16-
TWAIN driver TWAIN is the most widely used protocol for physical document scanners. Almost all scanners in the market come with a TWAIN driver and are supported by TWAIN applications like the Dynamic Web TWAIN SDK.
16+
TWAIN is the most widely used protocol for physical document scanners. Almost all scanners in the market come with a TWAIN driver and are supported by TWAIN applications like the Dynamic Web TWAIN SDK.
17+
18+
`WIA` stands for <a href="https://docs.microsoft.com/en-us/windows/win32/wia/-wia-startpage" target="_blank">Windows Image Acquisition</a>, which is a Microsoft driver model for capturing digital images from various devices, such as scanners, cameras and other imaging devices. The WIA protocol is built-in and supported by Windows OS, so no extra driver installation is required. WIA offers standardized hardware compatibility and a stable driver environment, making it easier to integrate imaging capabilities into web scanning applications.
19+
20+
Prior to Dynamic Web TWAIN version 18.2, WIA drivers are not officially supported. But `WIA` devices can be used by `TWAIN` applications like `Dynamic Web TWAIN` through a `TWAIN compatibility layer`. This means `WIA` is not supported natively; therefore, when a device supports both `TWAIN` and `WIA`, `TWAIN` is the better option.
21+
22+
As of Dynamic Web TWAIN version 18.2, we officially support WIA 2.0 drivers. To make sure your web application works with WIA scanner drivers, please refer to the article: <a href="{{site.faq}}support-wia-scanner-drivers.html" target="_blank">How do I support WIA scanner drivers in my application?</a>
1723

18-
`WIA` refers to <a href="https://docs.microsoft.com/en-us/windows/win32/wia/-wia-startpage" target="_blank">Windows Image Acquisition</a>, which is the still image acquisition platform in the Windows family that enables imaging/graphics applications to interact with imaging hardware and standardizes the interaction between different applications and scanners.
1924

20-
`WIA` devices can be used by `TWAIN` applications like `Dynamic Web TWAIN` through a `TWAIN compatibility layer`. This means `WIA` is not supported natively; therefore, when a device supports both `TWAIN` and `WIA`, `TWAIN` is the better option.
2125

22-
By comparison, `WIA` can only control a very limited set of general capabilities of the device while `TWAIN` can control all standard and even custom capabilities of the device. Another thing is that `TWAIN` has three transfer modes (Native, Memory, File), while `WIA` only has two (Memory, File).

faq/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ permalink: /faq/
9292
<li><a href="{{site.faq}}scanner-not-shown-or-not-responding-in-the browser.html">Why is my scanner not shown or not responding in the browser?</a></li>
9393

9494
<li><a href="{{site.faq}}download-virtual-scanner-for-testing.html">Download virtual scanner for testing</a></li>
95+
96+
<li><a href="{{site.faq}}support-wia-scanner-drivers.html">How can I support WIA scanner drivers in my application?</a></li>
97+
9598
</ol>
9699

97100
## Image Viewer
@@ -361,6 +364,8 @@ permalink: /faq/
361364
<li><a href="{{site.faq}}type-error-appendchild.html">Error Message - Uncaught TypeError: Cannot read properties of null (reading 'appendChild') or Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'</a></li>
362365

363366
<li><a href="{{site.faq}}error-message-user-cancelled-the-operation.html">Error Message - User cancelled the operation</a></li>
367+
368+
<li><a href="{{site.faq}}the-loading-bar-keeps-spinning-when-capture-the-image-with-iphone.html">The loading bar keeps spinning when capture the image with iPhone.</a></li>
364369
</ol>
365370

366371
## Licensing and Purchase

faq/support-wia-scanner-drivers.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
layout: default-layout
3+
noTitleIndex: true
4+
needAutoGenerateSidebar: true
5+
title: How can I support WIA scanner drivers in my application?
6+
keywords: Dynamic Web TWAIN, Capture/ Image Source, WIA
7+
breadcrumbText: How can I support WIA scanner drivers in my application?
8+
description: How can I support WIA scanner drivers in my application?
9+
permalink: /faq/support-wia-scanner-drivers.html
10+
---
11+
12+
# Capture/Image Source
13+
14+
## How can I support WIA scanner drivers in my application?
15+
16+
Prior to Dynamic Web TWAIN version 18.2, WIA drivers are not supported and TWAIN drivers are recommended. Please refer to <a href="{{site.faq}}difference-between-Twain-and-wia.html" target="_blank">this article</a> for the differences between WIA and TWAIN drivers.
17+
18+
As of Dynamic Web TWAIN version 18.2, we officially support WIA 2.0. By comparison, `WIA` can only control a very limited set of general capabilities of the device, while `TWAIN` can control all standard and even custom capabilities of the device. In addition, `WIA` has only two transfer modes (Memory, File), while `TWAIN` has three (Native, Memory, File).
19+
20+
Since Dynamic Web TWAIN v18.0, we introduced a new set of scanner related APIs.
21+
To compatible with both TWAIN and WIA 2.0,
22+
- If your application is already using the new set of APIs below, no application change is required.
23+
- If not, replace the old APIs with the matching new APIs.
24+
25+
| New APIs (supports WIA) | Old APIs |
26+
|:-|:-|
27+
| [GetDeviceAsync()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#getdevicesasync) | [GetSourceNames()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#getsourcenames), [GetSourceNamesAsync()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#getsourcenamesasync)|
28+
| [SelectDeviceAsync()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#selectdeviceasync) | [SelectSourceByIndex()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#selectsourcebyindex), [SelectSourceByIndexAsync()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#selectsourcebyindexasync) |
29+
| [SelectSourceAsync()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#selectsourceasync) | [SelectSource()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#selectsource) |
30+
| [AcquireImageAsync()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#acquireimageasync) | [AcquireImage()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#acquireimage) |
31+
32+
### Example Code
33+
34+
```javascript
35+
DWObject.GetDevicesAsync(Dynamsoft.DWT.EnumDWT_DeviceType.TWAINSCANNER|Dynamsoft.DWT.EnumDWT_DeviceType.WIASCANNER).then((deviceList)=>{
36+
return DWObject.SelectDeviceAsync(deviceList[0]) //Select the first device
37+
}).then(()=>{
38+
return DWObject.AcquireImageAsync({})
39+
}).catch((e)=>{
40+
console.error(e)
41+
})
42+
```
43+
44+
### Difference between the WIASCANNER and WIATWAINSCANNER DeviceType
45+
To support the WIA protocol in v18.2+, we added a new Enumaration `WIASCANNER` to [Dynamsoft.DWT.EnumDWT_DeviceType](https://www.dynamsoft.com/web-twain/docs/info/api/Dynamsoft_Enum.html?ver=latest&&cVer=true#dynamsoftdwtenumdwt_devicetype) . The enumaration named `WIATWAINSCANNER` represents WIA sources mapped through the TWAIN protocol after packaging by Microsoft. It was used in previous versions of Dynamic Web TWAIN and it will continue to be supported.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
layout: default-layout
3+
noTitleIndex: true
4+
needAutoGenerateSidebar: true
5+
title: The loading bar keeps spinning when capture the image with iPhone.
6+
keywords: Dynamic Web TWAIN, Error Troubleshooting, wasm, iphone
7+
breadcrumbText: The loading bar keeps spinning when capture the image with iPhone.
8+
description: The loading bar keeps spinning when capture the image with iPhone.
9+
permalink: /faq/the-loading-bar-keeps-spinning-when-capture-the-image-with-iphone.html
10+
---
11+
12+
# Error Troubleshooting
13+
14+
## The loading bar keeps spinning when capturing images with iPhone.
15+
16+
### Symptom
17+
18+
iOS 16.4 was released on March 27th, 2023. In this version, all browsers on iOS have begun to support `OffscreenCanvas`. Unfortunately, Apple's implementation of the API is still incomplete and is missing an important feature: "webgl context". Please see the MDN docs on [OffscreenCanvas](https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas) for more details.
19+
20+
### Cause
21+
22+
`OffscreenCanvas` is utilized in all versions of the Dynamic Web TWAIN Mobile Web Capture Edition. After you upgrade your iOS to v16.4, the loading bar will keep spinning when you try to capture an image. Note that the Service Edition is not affected by this issue.
23+
24+
### Resolution
25+
26+
Add the following lines of code to disable the API.
27+
28+
```javascript
29+
if (Dynamsoft.navInfoSync.biPhone || Dynamsoft.navInfoSync.biPad) {
30+
window.OffscreenCanvas = null
31+
}
32+
```
33+
34+
> If the resolution doesn't work for you, please [contact us](https://www.dynamsoft.com/company/contact/).

getstarted/vue.md

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ permalink: /indepth/development/vue.html
1212

1313
[Vue](https://vuejs.org/) is a progressive framework for building user interfaces. Check out the following guide on how to integrate `DWT` into a Vue application.
1414

15+
<div class="multi-panel-switching-prefix"></div>
16+
17+
- [Vue](#vue)
18+
- [Vue 3](#vue3)
19+
20+
<div class="multi-panel-start"></div>
21+
1522
## Preparation
1623

1724
Make sure you have [node](https://nodejs.org/), [yarn](https://yarnpkg.com/cli/install), and [Vue CLI](https://cli.vuejs.org/) installed. `node 14.4.0` , `yarn 1.22.4`, and `@vue/cli 4.46` are used in the example below.
@@ -203,9 +210,200 @@ If you have installed `DWT` and have configured a valid `ProductKey` . You will
203210

204211
You should be able to open a file or capture an image.
205212

213+
<div class="multi-panel-end"></div>
214+
215+
<div class="multi-panel-start"></div>
216+
217+
## Preparation
218+
219+
The recommended version for Vue and Node is `v3.2.22` and `v16+` respectively.
220+
221+
## Create the sample project
222+
223+
### Create a bootstrapped raw Vue 3 application
224+
225+
Assume the project name is "dwt-vue3"
226+
227+
``` cmd
228+
npm init vue@latest
229+
```
230+
231+
### Navigate to the root directory of the application and install the `dwt` and `ncp` package
232+
233+
``` cmd
234+
cd dwt-vue3
235+
```
236+
237+
``` cmd
238+
npm install
239+
```
240+
241+
``` cmd
242+
npm install dwt
243+
```
244+
245+
``` cmd
246+
npm install ncp
247+
```
248+
249+
## Configure the project
250+
251+
Open `package.json` and change `scripts` as seen below:
252+
253+
``` json
254+
"scripts": {
255+
"dev": "ncp node_modules/dwt/dist public/dwt-resources && vite",
256+
"build": "ncp node_modules/dwt/dist public/dwt-resources && vite build",
257+
"preview": "vite preview"
258+
},
259+
```
260+
261+
> The change ensures the static files required to run `DWT` are copied over to the resulting built project.
262+
263+
## Start to implement
264+
265+
### Edit the default component
266+
267+
Create `localScan.vue` in the folder /src/components
268+
269+
```html
270+
<script setup>
271+
import Dynamsoft from "dwt";
272+
import { onMounted, onUnmounted, ref } from "vue";
273+
let selectedIndex = ref(0);
274+
let sourceList=ref([]);
275+
let DWObject;
276+
const containerId = "dwtcontrolContainer";
277+
onMounted(() => {
278+
/**
279+
* ResourcesPath & ProductKey must be set in order to use the library!
280+
*/
281+
Dynamsoft.DWT.AutoLoad = false;
282+
Dynamsoft.DWT.ResourcesPath = "/dwt-resources";
283+
Dynamsoft.DWT.ProductKey ="YOUR-PRODUCT-KEY";
284+
Dynamsoft.DWT.Containers = [
285+
{
286+
WebTwainId: "dwtObject",
287+
ContainerId: containerId,
288+
Width: "500px",
289+
Height: "600px",
290+
},
291+
];
292+
Dynamsoft.DWT.RegisterEvent("OnWebTwainReady", () => {
293+
Dynamsoft_OnReady();
294+
});
295+
Dynamsoft.DWT.Load();
296+
});
297+
onUnmounted(()=>{
298+
Dynamsoft.DWT.Unload();
299+
})
300+
function Dynamsoft_OnReady() {
301+
DWObject = Dynamsoft.DWT.GetWebTwain(containerId);
302+
DWObject.GetDevicesAsync()
303+
.then((deviceList) => {
304+
sourceList.value = deviceList;
305+
})
306+
.catch((e) => {
307+
console.error(e);
308+
});
309+
}
310+
/**
311+
* Acquire images from scanners
312+
*/
313+
function acquireImage() {
314+
DWObject.SelectDeviceAsync(sourceList.value[selectedIndex.value])
315+
.then(() => {
316+
return DWObject.AcquireImageAsync({IfCloseSourceAfterAcquire:true});
317+
})
318+
.catch((e) => {
319+
console.error(e);
320+
})
321+
}
322+
323+
/**
324+
* Open local images.
325+
*/
326+
function openImage() {
327+
DWObject.IfShowFileDialog = true;
328+
/**
329+
* Note:
330+
* This following line of code uses the PDF Rasterizer which is an extra add-on that is licensed seperately
331+
*/
332+
DWObject.Addon.PDF.SetConvertMode(Dynamsoft.DWT.EnumDWT_ConvertMode.CM_RENDERALL);
333+
DWObject.LoadImageEx(
334+
"",
335+
Dynamsoft.DWT.EnumDWT_ImageType.IT_ALL,
336+
() => {
337+
//success
338+
},
339+
() => {
340+
//failure
341+
}
342+
);
343+
}
344+
</script>
345+
346+
<template>
347+
<div>
348+
<select v-model="selectedIndex">
349+
<option
350+
v-for="(source, index) in sourceList"
351+
:value="index"
352+
:key="index"
353+
>
354+
{{ source.displayName }}
355+
</option>
356+
</select>
357+
<button @click="acquireImage()">Acquire Images</button>
358+
<button @click="openImage()">Open Documents</button>
359+
<div :id="containerId"></div>
360+
</div>
361+
</template>
362+
363+
<style scoped></style>
364+
```
365+
366+
> Note:
367+
> * `containerId` specifies the DIV to create `DWT` viewer, which is defined in the `template`.
368+
> * `OnWebTwainReady` is the callback triggered when `DWT` initialization succeeds.
369+
> * `ProductKey` must be set to a valid trial or full key.
370+
> * `ResourcesPath` is set to the location of the static files mentioned in [Configure the project](#configure-the-project).
371+
372+
Change the file /src/App.vue
373+
374+
```html
375+
<script setup>
376+
import HelloWorld from './components/localScan.vue'
377+
</script>
378+
379+
<template>
380+
<HelloWorld />
381+
</template>
382+
383+
<style scoped>
384+
</style>
385+
```
386+
387+
### Try running the project
388+
389+
``` cmd
390+
npm run dev
391+
```
392+
393+
#### On desktop
394+
395+
If you have installed `DWT` and have configured a valid `ProductKey` . You will have a working page to scan documents from your scanner now. Otherwise, you should see instructions on [this page]({{site.indepth}}features/initialize.html#installation-of-the-dynamsoft-service) that guides you on installing the library.
396+
397+
#### On mobile
398+
399+
For Android, the scanners that support ESCL can be used.
400+
206401
## Official Samples
207402

208403
Check out the following sample project:
209404

210405
* [dwt-vue](https://github.com/Dynamsoft/web-twain-vue-advanced)
211406

407+
<div class="multi-panel-end"></div>
408+
409+
<div class="multi-panel-switching-end"></div>

0 commit comments

Comments
 (0)