Skip to content

Commit 7a3734a

Browse files
authored
Merge pull request #596 from dynamsoft-docs/preview
Preview
2 parents 9e2c485 + 6f2194f commit 7a3734a

File tree

1 file changed

+87
-4
lines changed

1 file changed

+87
-4
lines changed

info/api/WebTwain_Acquire.md

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,24 @@ CloseSource(): boolean;
336336
</table>
337337
</div>
338338

339+
**Example**
340+
341+
```javascript
342+
// Close the scanner source in the success/failure callback after all images are acquired. In this case, the source can be freed and used by others.
343+
DWObject.OpenSource();
344+
DWObject.AcquireImage(successCallback,failureCallback);
345+
346+
function successCallback() {
347+
console.log("successful");
348+
DWObject.CloseSource();
349+
}
350+
351+
function failureCallback(errorCode, errorString) {
352+
alert(errorString);
353+
DWObject.CloseSource();
354+
}
355+
```
356+
339357
---
340358

341359
## CloseSourceAsync
@@ -539,6 +557,15 @@ OpenSource(): boolean;
539557
</table>
540558
</div>
541559

560+
**Example**
561+
562+
```javascript
563+
DWObject.GetSourceNames(); // for example ['PaperStream IP fi-7300NX Net', 'TWAIN2 FreeImage Software Scanner']
564+
DWObject.SelectSourceByIndex(0); // choose scanner with the name "PaperStream IP fi-7300NX Net"
565+
DWObject.OpenSource();
566+
DWObject.AcquireImage();
567+
```
568+
542569
---
543570

544571
## OpenSourceAsync
@@ -666,6 +693,12 @@ interface Version {
666693
</table>
667694
</div>
668695

696+
**Example**
697+
698+
```javascript
699+
DWObject.GetSourceNames(); // return a list of scanner sources such as ['PaperStream IP fi-7300NX Net', 'TWAIN2 FreeImage Software Scanner']
700+
```
701+
669702
---
670703

671704
## GetSourceNamesAsync
@@ -810,7 +843,6 @@ SelectSourceAsync(deviceType?: Dynamsoft.DWT.EnumDWT_DeviceType | number): Promi
810843

811844
</table>
812845
</div>
813-
---
814846

815847
**Example**
816848

@@ -825,6 +857,8 @@ DWObject.SelectSourceAsync()
825857
});
826858
```
827859

860+
---
861+
828862
## SelectSourceByIndex
829863

830864
Select a data source by its index.
@@ -866,7 +900,8 @@ SelectSourceByIndex(index: number): boolean;
866900
**Example**
867901

868902
```javascript
869-
DWObject.SelectSourceByIndex(0);
903+
DWObject.GetSourceNames(); // for example ['PaperStream IP fi-7300NX Net', 'TWAIN2 FreeImage Software Scanner']
904+
DWObject.SelectSourceByIndex(0); // choose scanner with the name "PaperStream IP fi-7300NX Net"
870905
DWObject.OpenSource();
871906
DWObject.AcquireImage();
872907
```
@@ -967,7 +1002,7 @@ SetOpenSourceTimeout(duration: number): boolean;
9671002

9681003
```javascript
9691004
DWObject.SelectSource(function () {
970-
DWObject.SetOpenSourceTimeout(3000);
1005+
DWObject.SetOpenSourceTimeout(3000); // stop the opening process if the source cannot be opened within 3000 ms.
9711006
DWObject.OpenSource();
9721007
DWObject.AcquireImage();
9731008
});
@@ -1351,6 +1386,13 @@ CloseSourceManager(): boolean;
13511386

13521387
</table>
13531388
</div>
1389+
1390+
**Example**
1391+
1392+
```javascript
1393+
DWObject.CloseSourceManager();
1394+
```
1395+
13541396
---
13551397

13561398
## CloseSourceManagerAsync
@@ -1507,10 +1549,15 @@ GetCustomDSData(fileName: string): boolean;
15071549
</table>
15081550
</div>
15091551

1552+
**Usage notes**
1553+
1554+
Typically, the data source data file is set by the method [SetCustomDSData()](#setcustomdsdata).
1555+
15101556
**Example**
15111557

15121558
```javascript
1513-
DWObject.GetCustomDSData("C:\\customDSData");
1559+
// Please note, the API only works for TWAIN driver.
1560+
DWObject.GetCustomDSData("C:\\Users\\UserName\\Desktop\\ProfileName");
15141561
```
15151562

15161563
---
@@ -1549,6 +1596,17 @@ GetCustomDSDataEx(): string;
15491596
</table>
15501597
</div>
15511598

1599+
**Usage notes**
1600+
1601+
Typically, the data source data file is set by the method [SetCustomDSDataEx()](#setcustomdsdataex).
1602+
1603+
**Example**
1604+
1605+
```javascript
1606+
// Please note, the API only works for TWAIN driver.
1607+
DWObject.GetCustomDSDataEx(); // Return a base64 string
1608+
```
1609+
15521610
---
15531611

15541612
## GetSourceNameItems
@@ -1589,6 +1647,13 @@ GetSourceNameItems(index: number): string;
15891647
</table>
15901648
</div>
15911649

1650+
**Example**
1651+
1652+
```javascript
1653+
DWObject.GetSourceNames(); // [scanner 1, scanner 2, scanner 3...]
1654+
DWObject.GetSourceNameItems(0); // return the name of scanner 1
1655+
```
1656+
15921657
---
15931658

15941659
## OpenSourceManager
@@ -1629,6 +1694,12 @@ OpenSourceManager(): boolean;
16291694

16301695
If application identification needs to be set, it should be set before this API.
16311696

1697+
**Example**
1698+
1699+
```javascript
1700+
DWObject.OpenSourceManager();
1701+
```
1702+
16321703
---
16331704

16341705
## OpenSourceManagerAsync
@@ -1792,6 +1863,13 @@ SetCustomDSData(fileName: string): boolean;
17921863

17931864
Typically, the data source data file is created by the method [GetCustomDSData()](#getcustomdsdata).
17941865

1866+
**Example**
1867+
1868+
```javascript
1869+
// Please note, the API only works for TWAIN driver.
1870+
DWObject.SetCustomDSData("C:\\Users\\UserName\\Desktop\\ProfileName");
1871+
```
1872+
17951873
---
17961874

17971875
## SetCustomDSDataEx
@@ -1836,6 +1914,11 @@ SetCustomDSDataEx(dsDataString: string): boolean;
18361914

18371915
Typically the data source data string is created by the method [GetCustomDSDataEx()](#getcustomdsdataex)
18381916

1917+
```javascript
1918+
// Please note, the API only works for TWAIN driver.
1919+
DWObject.SetCustomDSData("the base64 string of your profile");
1920+
```
1921+
18391922
---
18401923

18411924
## SetFileXferInfo

0 commit comments

Comments
 (0)