Skip to content

Commit 191f9fb

Browse files
update to web-twain 18.5.1
1 parent f401989 commit 191f9fb

3 files changed

Lines changed: 115 additions & 115 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@angular/router": "~16.0.0",
2323
"@ng-bootstrap/ng-bootstrap": "~15.0.0",
2424
"bootstrap": "^5.3.0",
25-
"dwt": "18.5.0",
25+
"dwt": "18.5.1",
2626
"rxjs": "~6.6.0",
2727
"tslib": "^2.1.0",
2828
"zone.js": "~0.13.0"

src/app/dwt.service.ts

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export class DwtService {
1919
/**
2020
* WebTwain objects
2121
*/
22-
protected _DWObject: WebTwain = null;
23-
protected _DWObjectEx: WebTwain = null;
22+
protected _DWTObject: WebTwain = null;
23+
protected _DWTObjectEx: WebTwain = null;
2424
/**
2525
* Global environment that is detected by the dwt library.
2626
*/
@@ -90,7 +90,7 @@ export class DwtService {
9090
}
9191

9292
mountDWT(UseService?: boolean): Promise<any> {
93-
this._DWObject = null;
93+
this._DWTObject = null;
9494
return new Promise((res, rej) => {
9595
let dwtInitialConfig: DWTInitialConfig = {
9696
WebTwainId: "dwtObject"
@@ -116,14 +116,14 @@ export class DwtService {
116116
dwtInitialConfig.UseLocalService = Dynamsoft.DWT.UseLocalService;
117117
Dynamsoft.DWT.CreateDWTObjectEx(
118118
dwtInitialConfig,
119-
(_DWObject) => {
120-
this._DWObject = _DWObject;
121-
/*this._DWObject.IfShowProgressBar = false;
122-
this._DWObject.IfShowCancelDialogWhenImageTransfer = false;*/
119+
(_DWTObject) => {
120+
this._DWTObject = _DWTObject;
121+
/*this._DWTObject.IfShowProgressBar = false;
122+
this._DWTObject.IfShowCancelDialogWhenImageTransfer = false;*/
123123
/**
124124
* The event OnBufferChanged is used here for monitoring the image buffer.
125125
*/
126-
this._DWObject.RegisterEvent("OnBufferChanged", (changedIndexArray, operationType, changedIndex, imagesCount) => {
126+
this._DWTObject.RegisterEvent("OnBufferChanged", (changedIndexArray, operationType, changedIndex, imagesCount) => {
127127
switch (operationType) {
128128
/** reserved space
129129
* type: 1-Append(after index), 2-Insert(before index), 3-Remove, 4-Edit(Replace), 5-Index Change
@@ -136,12 +136,12 @@ export class DwtService {
136136
default: break;
137137
}
138138
this.bufferSubject.next("changed");
139-
if (this._DWObject.HowManyImagesInBuffer === 0)
139+
if (this._DWTObject.HowManyImagesInBuffer === 0)
140140
this.bufferSubject.next("empty");
141141
else
142142
this.bufferSubject.next("filled");
143143
});
144-
res(_DWObject);
144+
res(_DWTObject);
145145
},
146146
(errorString) => {
147147
rej(errorString);
@@ -160,20 +160,20 @@ export class DwtService {
160160
});
161161
}
162162
/**
163-
* Create an extra WebTwain instance _DWObjectEx
163+
* Create an extra WebTwain instance _DWTObjectEx
164164
* This is used solely for displaying & capturing from a video stream.
165165
*/
166166
mountVideoContainer(): Promise<any> {
167-
this._DWObjectEx = null;
167+
this._DWTObjectEx = null;
168168
return new Promise((res, rej) => {
169-
if (this._DWObject) {
169+
if (this._DWTObject) {
170170
let dwtInitialConfig: DWTInitialConfig = {
171171
WebTwainId: "videoContainer"
172172
};
173173
Dynamsoft.DWT.CreateDWTObjectEx(
174174
dwtInitialConfig,
175175
(_container) => {
176-
this._DWObjectEx = _container;
176+
this._DWTObjectEx = _container;
177177
res(_container);
178178
},
179179
(errorString) => {
@@ -201,11 +201,11 @@ export class DwtService {
201201
*/
202202
getDevices(bfromCamera): Promise<Device[]> {
203203
return new Promise((res, rej) => {
204-
let _dwt = this._DWObject;
205-
if (this._DWObjectEx)
206-
_dwt = this._DWObjectEx;
204+
let _dwt = this._DWTObject;
205+
if (this._DWTObjectEx)
206+
_dwt = this._DWTObjectEx;
207207
this.devices = [];
208-
this._DWObject.GetDevicesAsync().then((devicesList)=>{
208+
this._DWTObject.GetDevicesAsync().then((devicesList)=>{
209209
for (let i = 0; i < devicesList.length; i++) {
210210
this.devices.push({ deviceId: Math.floor(Math.random() * 100000).toString(), name: (i + 1).toString() + "." + devicesList[i].displayName, label: devicesList[i].displayName, type: "scanner", deviceInfo: devicesList[i] });
211211
}
@@ -238,7 +238,7 @@ export class DwtService {
238238
* Retrieve detailed information of the devices.
239239
*/
240240
getDeviceDetails() {
241-
return this._DWObject.GetSourceNames(true);
241+
return this._DWTObject.GetSourceNames(true);
242242
}
243243
/**
244244
* Select a scanner or camera by name.
@@ -254,9 +254,9 @@ export class DwtService {
254254
this.devices.forEach((value, index) => {
255255
if (value && value.name === name) {
256256
if (index > this._scannersCount - 1) {
257-
let _dwt = this._DWObject;
258-
if (this._DWObjectEx)
259-
_dwt = this._DWObjectEx;
257+
let _dwt = this._DWTObject;
258+
if (this._DWTObjectEx)
259+
_dwt = this._DWTObjectEx;
260260
if (this.bUseCameraViaDirectShow) {
261261
_dwt.Addon.Webcam.StopVideo();
262262
if (_dwt.Addon.Webcam.SelectSource(value.label)) {
@@ -274,7 +274,7 @@ export class DwtService {
274274
}
275275
else {
276276
waitForAnotherPromise = true;
277-
this._DWObject.SelectDeviceAsync(value.deviceInfo).then(()=>{
277+
this._DWTObject.SelectDeviceAsync(value.deviceInfo).then(()=>{
278278
this._selectedDevice = name;
279279
this.generalSubject.next({ type: "deviceName", deviceName: this._selectedDevice });
280280
res(true);
@@ -367,12 +367,12 @@ export class DwtService {
367367
return new Promise((res, rej) => {
368368
if (this._selectedDevice !== "") {
369369
if (this._useCamera) {
370-
if (this._DWObjectEx) {
370+
if (this._DWTObjectEx) {
371371
if (this.bUseCameraViaDirectShow) {
372-
this._DWObjectEx.Addon.Webcam.CaptureImage(() => {
373-
this.getBlob([0], Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG, this._DWObjectEx)
374-
.then(blob => this._DWObject.LoadImageFromBinary(blob, () => {
375-
this._DWObjectEx.RemoveImage(0);
372+
this._DWTObjectEx.Addon.Webcam.CaptureImage(() => {
373+
this.getBlob([0], Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG, this._DWTObjectEx)
374+
.then(blob => this._DWTObject.LoadImageFromBinary(blob, () => {
375+
this._DWTObjectEx.RemoveImage(0);
376376
res(true);
377377
}, (errCode, errString) => rej(errString)));
378378
}, (errCode, errStr) => rej(errStr));
@@ -381,18 +381,18 @@ export class DwtService {
381381
rej("No WebTwain instanance for camera capture!");
382382
}
383383
} else {
384-
this._DWObject.SetOpenSourceTimeout(3000);
384+
this._DWTObject.SetOpenSourceTimeout(3000);
385385
if (bAdvanced) {
386-
if (this._DWObject.OpenSource()){
387-
this._DWObject.startScan(<ScanSetup>config);
386+
if (this._DWTObject.OpenSource()){
387+
this._DWTObject.startScan(<ScanSetup>config);
388388
} else {
389-
rej(this._DWObject.ErrorString);
389+
rej(this._DWTObject.ErrorString);
390390
}
391391
} else {
392-
this._DWObject.AcquireImageAsync(<DeviceConfiguration>config).then(()=>{
393-
return this._DWObject.CloseSourceAsync();
392+
this._DWTObject.AcquireImageAsync(<DeviceConfiguration>config).then(()=>{
393+
return this._DWTObject.CloseSourceAsync();
394394
}).then(()=>{
395-
this._DWObject.CloseWorkingProcess();
395+
this._DWTObject.CloseWorkingProcess();
396396
}).catch((exp) =>{
397397
rej(exp.message);
398398
});
@@ -409,19 +409,19 @@ export class DwtService {
409409
*/
410410
load(files?: FileList): Promise<any> {
411411
return new Promise((res, rej) => {
412-
this._DWObject.Addon.PDF.SetReaderOptions({
412+
this._DWTObject.Addon.PDF.SetReaderOptions({
413413
convertMode: Dynamsoft.DWT.EnumDWT_ConvertMode.CM_AUTO,
414414
renderOptions: {
415415
resolution: 200
416416
}
417417
});
418-
this._DWObject.IfShowFileDialog = true;
419-
this._DWObject.RegisterEvent("OnPostLoad", (
418+
this._DWTObject.IfShowFileDialog = true;
419+
this._DWTObject.RegisterEvent("OnPostLoad", (
420420
directory: string,
421421
fileName: string,
422422
fileType: DynamsoftEnumsDWT.EnumDWT_ImageType) => {
423423
});
424-
this._DWObject.LoadImageEx("", -1, () => { res(true); }, (errCode, errStr) => rej(errStr))
424+
this._DWTObject.LoadImageEx("", -1, () => { res(true); }, (errCode, errStr) => rej(errStr))
425425
});
426426
}
427427
/**
@@ -443,16 +443,16 @@ export class DwtService {
443443
* @param config Configuration for the read.
444444
*/
445445
readBarcode(config?: any) {
446-
let _index = this._DWObject.CurrentImageIndexInBuffer;
446+
let _index = this._DWTObject.CurrentImageIndexInBuffer;
447447
if (config && config.index !== undefined) {
448448
_index = Math.floor(config.index);
449-
if (_index < 0 || _index > this._DWObject.HowManyImagesInBuffer - 1)
450-
_index = this._DWObject.CurrentImageIndexInBuffer;
449+
if (_index < 0 || _index > this._DWTObject.HowManyImagesInBuffer - 1)
450+
_index = this._DWTObject.CurrentImageIndexInBuffer;
451451
}
452452
Dynamsoft.Lib.showMask();
453-
this._DWObject.Addon.BarcodeReader.getRuntimeSettings()
453+
this._DWTObject.Addon.BarcodeReader.getRuntimeSettings()
454454
.then(settings => {
455-
if (this._DWObject.GetImageBitDepth(_index) === 1) {
455+
if (this._DWTObject.GetImageBitDepth(_index) === 1) {
456456
settings.scaleDownThreshold = 214748347;
457457
} else {
458458
settings.scaleDownThreshold = 2300;
@@ -537,11 +537,11 @@ export class DwtService {
537537
this.barcodeSubject.next({ done: true });
538538
Dynamsoft.Lib.hideMask();
539539
};
540-
this._DWObject.Addon.BarcodeReader.updateRuntimeSettings(settings)
540+
this._DWTObject.Addon.BarcodeReader.updateRuntimeSettings(settings)
541541
.then(_ => {
542542
let decoderFunc = () => {
543543
try {
544-
this._DWObject.Addon.BarcodeReader.decode(index)
544+
this._DWTObject.Addon.BarcodeReader.decode(index)
545545
.then(textResults => {
546546
this.barcodeResults.push(textResults);
547547
bHasCallback ? callback() : outputResults();
@@ -597,7 +597,7 @@ export class DwtService {
597597
*/
598598
getBlob(indices: number[], type: DynamsoftEnumsDWT.EnumDWT_ImageType, dwt?: WebTwain): Promise<any> {
599599
return new Promise((res, rej) => {
600-
let _dwt = this._DWObject;
600+
let _dwt = this._DWTObject;
601601
if (dwt)
602602
_dwt = dwt;
603603
switch (type) {
@@ -619,7 +619,7 @@ export class DwtService {
619619
*/
620620
getBase64(indices: number[], type: DynamsoftEnumsDWT.EnumDWT_ImageType, dwt?: WebTwain): Promise<any> {
621621
return new Promise((res, rej) => {
622-
let _dwt = this._DWObject;
622+
let _dwt = this._DWTObject;
623623
if (dwt)
624624
_dwt = dwt;
625625
if (type === Dynamsoft.DWT.EnumDWT_ImageType.IT_ALL)
@@ -707,13 +707,13 @@ export class DwtService {
707707
res({ name: _name, path: _path });
708708
}, f = (errCode, errStr) => rej(errStr);
709709
switch (_type) {
710-
case 0: this._DWObject.SaveAsBMP(_path, indices[0], s, f); break;
711-
case 1: this._DWObject.SaveAsJPEG(_path, indices[0], s, f); break;
712-
case 2: this._DWObject.SaveAsTIFF(_path, indices[0], s, f); break;
713-
case 3: this._DWObject.SaveAsPNG(_path, indices[0], s, f); break;
714-
case 4: this._DWObject.SaveAsPDF(_path, indices[0], s, f); break;
715-
case 7: this._DWObject.SaveSelectedImagesAsMultiPagePDF(_path, s, f); break;
716-
case 8: this._DWObject.SaveSelectedImagesAsMultiPageTIFF(_path, s, f); break;
710+
case 0: this._DWTObject.SaveAsBMP(_path, indices[0], s, f); break;
711+
case 1: this._DWTObject.SaveAsJPEG(_path, indices[0], s, f); break;
712+
case 2: this._DWTObject.SaveAsTIFF(_path, indices[0], s, f); break;
713+
case 3: this._DWTObject.SaveAsPNG(_path, indices[0], s, f); break;
714+
case 4: this._DWTObject.SaveAsPDF(_path, indices[0], s, f); break;
715+
case 7: this._DWTObject.SaveSelectedImagesAsMultiPagePDF(_path, s, f); break;
716+
case 8: this._DWTObject.SaveSelectedImagesAsMultiPageTIFF(_path, s, f); break;
717717
default: break;
718718
}
719719
});
@@ -723,8 +723,8 @@ export class DwtService {
723723
if (showDialog) {
724724
this.fileSavingPath = "";
725725
this.fileActualName = "";
726-
this._DWObject.IfShowFileDialog = false;
727-
this._DWObject.RegisterEvent("OnGetFilePath", (isSave, filesCount, index, directory, _fn) => {
726+
this._DWTObject.IfShowFileDialog = false;
727+
this._DWTObject.RegisterEvent("OnGetFilePath", (isSave, filesCount, index, directory, _fn) => {
728728
if(isSave && filesCount != -1){
729729
if (directory === "" && _fn === "") {
730730
rej("User cancelled the operation.")
@@ -737,7 +737,7 @@ export class DwtService {
737737
});
738738
if(this.runningEnvironment.bMac)
739739

740-
this._DWObject.ShowFileDialog(
740+
this._DWTObject.ShowFileDialog(
741741
true,
742742
"TIF,TIFF,JPG,JPEG,PNG,PDF",
743743
0,
@@ -748,7 +748,7 @@ export class DwtService {
748748
0
749749
);
750750
else
751-
this._DWObject.ShowFileDialog(
751+
this._DWTObject.ShowFileDialog(
752752
true,
753753
"BMP,TIF,JPG,PNG,PDF|*.bmp;*.tif;*.png;*.jpg;*.pdf;*.tiff;*.jpeg",
754754
0,
@@ -760,7 +760,7 @@ export class DwtService {
760760
);
761761

762762
} else {
763-
this._DWObject.IfShowFileDialog = false;
763+
this._DWTObject.IfShowFileDialog = false;
764764
res(saveInner(filePath, fileName, type));
765765
}
766766
});
@@ -793,7 +793,7 @@ export class DwtService {
793793
savedDir = protocol + window.location.hostname + ":" + _strPort + "/uploaded/";
794794
url = protocol + window.location.hostname + ":" + _strPort + strActionPage;
795795
}
796-
this._DWObject.HTTPUpload(
796+
this._DWTObject.HTTPUpload(
797797
url,
798798
indices,
799799
type,

0 commit comments

Comments
 (0)