diff --git a/README.md b/README.md
index 25c96ab..a56dee8 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ This project was bootstrapped with [Angular CLI](https://github.com/angular/angu
* Barcode reading
## Usage
-Environment: Node.js v16.20.0
+Environment: Node.js version - 22.14.0, Angular version - v19.2.1
1. Apply for a [30-day free trial license](https://www.dynamsoft.com/customer/license/trialLicense?product=dwt) of Dynamic Web TWAIN.
2. Update the license key in two files `src\environments\environment.ts` and `src\environments\environment.prod.ts` :
diff --git a/angular.json b/angular.json
index 441a0ba..991a0a7 100644
--- a/angular.json
+++ b/angular.json
@@ -16,8 +16,10 @@
"outputPath": "dist/dwt-angular-advanced",
"index": "src/index.html",
"main": "src/main.ts",
- "polyfills": "src/polyfills.ts",
- "tsConfig": "tsconfig.app.json",
+ "polyfills": [
+ "zone.js"
+ ],
+ "tsConfig": "tsconfig.json",
"aot": true,
"assets": [
"src/favicon.ico",
@@ -42,96 +44,38 @@
"with": "src/environments/environment.prod.ts"
}
],
- "optimization": true,
+ "optimization": {
+ "scripts": false,
+ "styles": {
+ "minify": true,
+ "inlineCritical": false
+ },
+ "fonts": true
+ },
"outputHashing": "all",
- "sourceMap": false,
- "extractCss": true,
+ "sourceMap": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
- "buildOptimizer": true,
- "budgets": [
- {
- "type": "initial",
- "maximumWarning": "2mb",
- "maximumError": "5mb"
- },
- {
- "type": "anyComponentStyle",
- "maximumWarning": "6kb",
- "maximumError": "10kb"
- }
- ]
+ "buildOptimizer": false,
+ "budgets": []
}
- }
+ },
+ "defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
- "options": {
- "browserTarget": "dwt-angular-advanced:build"
- },
"configurations": {
"production": {
- "browserTarget": "dwt-angular-advanced:build:production"
+ "buildTarget": "dwt-angular-advanced:build:production"
}
- }
- },
- "extract-i18n": {
- "builder": "@angular-devkit/build-angular:extract-i18n",
- "options": {
- "browserTarget": "dwt-angular-advanced:build"
- }
- },
- "test": {
- "builder": "@angular-devkit/build-angular:karma",
- "options": {
- "main": "src/test.ts",
- "polyfills": "src/polyfills.ts",
- "tsConfig": "tsconfig.spec.json",
- "karmaConfig": "karma.conf.js",
- "assets": [
- "src/favicon.ico",
- "src/assets",
- {
- "glob": "**/*",
- "input": "./node_modules/dwt/dist",
- "output": "/assets/dwt-resources/"
- }
- ],
- "styles": [
- "src/styles.css",
- "node_modules/bootstrap/dist/css/bootstrap.min.css"
- ],
- "scripts": []
- }
- },
- "lint": {
- "builder": "@angular-devkit/build-angular:tslint",
- "options": {
- "tsConfig": [
- "tsconfig.app.json",
- "tsconfig.spec.json",
- "e2e/tsconfig.json"
- ],
- "exclude": [
- "**/node_modules/**"
- ]
- }
- },
- "e2e": {
- "builder": "@angular-devkit/build-angular:protractor",
- "options": {
- "protractorConfig": "e2e/protractor.conf.js",
- "devServerTarget": "dwt-angular-advanced:serve"
},
- "configurations": {
- "production": {
- "devServerTarget": "dwt-angular-advanced:serve:production"
- }
- }
+ "defaultConfiguration": "production"
}
}
}
},
- "defaultProject": "dwt-angular-advanced"
+ "cli": {
+ "analytics": false
+ }
}
diff --git a/package.json b/package.json
index d0027ed..7aeb4d4 100644
--- a/package.json
+++ b/package.json
@@ -4,47 +4,34 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
- "build": "ng build",
- "test": "ng test",
- "lint": "ng lint",
- "e2e": "ng e2e"
+ "build": "ng build"
},
"private": true,
"dependencies": {
- "@angular/animations": "~12.0.0",
- "@angular/common": "~12.0.0",
- "@angular/compiler": "~12.0.0",
- "@angular/core": "~12.0.0",
- "@angular/forms": "~12.0.0",
- "@angular/localize": "^12.0.0",
- "@angular/platform-browser": "~12.0.0",
- "@angular/platform-browser-dynamic": "~12.0.0",
- "@angular/router": "~12.0.0",
- "@ng-bootstrap/ng-bootstrap": "^11.0.0-beta.0",
- "bootstrap": "^5.0.0",
- "dwt": "18.2.0",
- "rxjs": "~6.6.0",
- "tslib": "^2.1.0",
- "zone.js": "~0.11.4"
+ "@angular/common": "19.2.2",
+ "@angular/compiler": "19.2.2",
+ "@angular/core": "19.2.2",
+ "@angular/forms": "19.2.2",
+ "@angular/platform-browser": "19.2.2",
+ "@angular/router": "19.2.2",
+ "@angular/elements": "19.2.2",
+ "@angular/build": "19.2.3",
+ "@angular-devkit/build-angular": "19.2.3",
+ "@ng-bootstrap/ng-bootstrap":"18.0.0",
+ "@angular/localize": "19.2.2",
+ "@angular/animations": "19.2.2",
+ "dwt": "19.1.0",
+ "rxjs": "~7.8.1",
+ "tslib": "^2.5.2",
+ "bootstrap": "^5.3.3"
},
"devDependencies": {
- "@angular-devkit/build-angular": "~12.0.0",
- "@angular/cli": "~12.0.0",
- "@angular/compiler-cli": "~12.0.0",
- "@types/node": "^12.11.1",
- "@types/jasmine": "~3.6.0",
- "@types/jasminewd2": "~2.0.3",
- "codelyzer": "^6.0.0",
- "jasmine-core": "~3.7.0",
- "jasmine-spec-reporter": "~5.0.0",
- "karma": "~6.3.0",
- "karma-chrome-launcher": "~3.1.0",
- "karma-coverage-istanbul-reporter": "~3.0.2",
- "karma-jasmine": "~4.0.0",
- "karma-jasmine-html-reporter": "^1.5.0",
+ "@angular/cli": "19.2.2",
+ "@angular/compiler-cli": "19.2.2",
+ "@types/node": "^22.13.10",
+ "codelyzer": "^6.0.2",
"protractor": "~7.0.0",
- "ts-node": "~8.3.0",
- "tslint": "~6.1.0",
- "typescript": "~4.2.3"
+ "ts-node": "^10.9.2",
+ "typescript": "^5.8.2"
}
}
diff --git a/server/package-lock.json b/server/package-lock.json
deleted file mode 100644
index d9223b3..0000000
--- a/server/package-lock.json
+++ /dev/null
@@ -1,379 +0,0 @@
-{
- "name": "formidable-server",
- "version": "0.1.0",
- "lockfileVersion": 1,
- "requires": true,
- "dependencies": {
- "accepts": {
- "version": "1.3.7",
- "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
- "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
- "requires": {
- "mime-types": "~2.1.24",
- "negotiator": "0.6.2"
- }
- },
- "array-flatten": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
- "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
- },
- "body-parser": {
- "version": "1.19.0",
- "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
- "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
- "requires": {
- "bytes": "3.1.0",
- "content-type": "~1.0.4",
- "debug": "2.6.9",
- "depd": "~1.1.2",
- "http-errors": "1.7.2",
- "iconv-lite": "0.4.24",
- "on-finished": "~2.3.0",
- "qs": "6.7.0",
- "raw-body": "2.4.0",
- "type-is": "~1.6.17"
- }
- },
- "bytes": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
- "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
- },
- "content-disposition": {
- "version": "0.5.3",
- "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
- "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
- "requires": {
- "safe-buffer": "5.1.2"
- }
- },
- "content-type": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
- "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
- },
- "cookie": {
- "version": "0.4.0",
- "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
- "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg=="
- },
- "cookie-signature": {
- "version": "1.0.6",
- "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
- "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
- },
- "debug": {
- "version": "2.6.9",
- "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
- "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
- "requires": {
- "ms": "2.0.0"
- }
- },
- "depd": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
- "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
- },
- "destroy": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
- "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
- },
- "ee-first": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
- "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
- },
- "encodeurl": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
- "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
- },
- "escape-html": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
- "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
- },
- "etag": {
- "version": "1.8.1",
- "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
- "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
- },
- "express": {
- "version": "4.17.1",
- "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
- "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
- "requires": {
- "accepts": "~1.3.7",
- "array-flatten": "1.1.1",
- "body-parser": "1.19.0",
- "content-disposition": "0.5.3",
- "content-type": "~1.0.4",
- "cookie": "0.4.0",
- "cookie-signature": "1.0.6",
- "debug": "2.6.9",
- "depd": "~1.1.2",
- "encodeurl": "~1.0.2",
- "escape-html": "~1.0.3",
- "etag": "~1.8.1",
- "finalhandler": "~1.1.2",
- "fresh": "0.5.2",
- "merge-descriptors": "1.0.1",
- "methods": "~1.1.2",
- "on-finished": "~2.3.0",
- "parseurl": "~1.3.3",
- "path-to-regexp": "0.1.7",
- "proxy-addr": "~2.0.5",
- "qs": "6.7.0",
- "range-parser": "~1.2.1",
- "safe-buffer": "5.1.2",
- "send": "0.17.1",
- "serve-static": "1.14.1",
- "setprototypeof": "1.1.1",
- "statuses": "~1.5.0",
- "type-is": "~1.6.18",
- "utils-merge": "1.0.1",
- "vary": "~1.1.2"
- }
- },
- "finalhandler": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
- "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
- "requires": {
- "debug": "2.6.9",
- "encodeurl": "~1.0.2",
- "escape-html": "~1.0.3",
- "on-finished": "~2.3.0",
- "parseurl": "~1.3.3",
- "statuses": "~1.5.0",
- "unpipe": "~1.0.0"
- }
- },
- "formidable": {
- "version": "1.2.2",
- "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.2.tgz",
- "integrity": "sha512-V8gLm+41I/8kguQ4/o1D3RIHRmhYFG4pnNyonvua+40rqcEmT4+V71yaZ3B457xbbgCsCfjSPi65u/W6vK1U5Q=="
- },
- "forwarded": {
- "version": "0.1.2",
- "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
- "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
- },
- "fresh": {
- "version": "0.5.2",
- "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
- "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
- },
- "http-errors": {
- "version": "1.7.2",
- "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
- "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
- "requires": {
- "depd": "~1.1.2",
- "inherits": "2.0.3",
- "setprototypeof": "1.1.1",
- "statuses": ">= 1.5.0 < 2",
- "toidentifier": "1.0.0"
- }
- },
- "iconv-lite": {
- "version": "0.4.24",
- "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
- "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
- "requires": {
- "safer-buffer": ">= 2.1.2 < 3"
- }
- },
- "inherits": {
- "version": "2.0.3",
- "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
- "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
- },
- "ipaddr.js": {
- "version": "1.9.1",
- "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
- "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
- },
- "media-typer": {
- "version": "0.3.0",
- "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
- "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
- },
- "merge-descriptors": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
- "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
- },
- "methods": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
- "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
- },
- "mime": {
- "version": "1.6.0",
- "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
- "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
- },
- "mime-db": {
- "version": "1.43.0",
- "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz",
- "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ=="
- },
- "mime-types": {
- "version": "2.1.26",
- "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz",
- "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==",
- "requires": {
- "mime-db": "1.43.0"
- }
- },
- "ms": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
- "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
- },
- "negotiator": {
- "version": "0.6.2",
- "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
- "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
- },
- "on-finished": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
- "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
- "requires": {
- "ee-first": "1.1.1"
- }
- },
- "parseurl": {
- "version": "1.3.3",
- "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
- "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
- },
- "path-to-regexp": {
- "version": "0.1.7",
- "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
- "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
- },
- "proxy-addr": {
- "version": "2.0.6",
- "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz",
- "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==",
- "requires": {
- "forwarded": "~0.1.2",
- "ipaddr.js": "1.9.1"
- }
- },
- "qs": {
- "version": "6.7.0",
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
- "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
- },
- "range-parser": {
- "version": "1.2.1",
- "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
- "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
- },
- "raw-body": {
- "version": "2.4.0",
- "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
- "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
- "requires": {
- "bytes": "3.1.0",
- "http-errors": "1.7.2",
- "iconv-lite": "0.4.24",
- "unpipe": "1.0.0"
- }
- },
- "safe-buffer": {
- "version": "5.1.2",
- "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
- "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
- },
- "safer-buffer": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
- "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
- },
- "send": {
- "version": "0.17.1",
- "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
- "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
- "requires": {
- "debug": "2.6.9",
- "depd": "~1.1.2",
- "destroy": "~1.0.4",
- "encodeurl": "~1.0.2",
- "escape-html": "~1.0.3",
- "etag": "~1.8.1",
- "fresh": "0.5.2",
- "http-errors": "~1.7.2",
- "mime": "1.6.0",
- "ms": "2.1.1",
- "on-finished": "~2.3.0",
- "range-parser": "~1.2.1",
- "statuses": "~1.5.0"
- },
- "dependencies": {
- "ms": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
- "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
- }
- }
- },
- "serve-static": {
- "version": "1.14.1",
- "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
- "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
- "requires": {
- "encodeurl": "~1.0.2",
- "escape-html": "~1.0.3",
- "parseurl": "~1.3.3",
- "send": "0.17.1"
- }
- },
- "setprototypeof": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
- "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
- },
- "statuses": {
- "version": "1.5.0",
- "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
- "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
- },
- "toidentifier": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
- "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
- },
- "type-is": {
- "version": "1.6.18",
- "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
- "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
- "requires": {
- "media-typer": "0.3.0",
- "mime-types": "~2.1.24"
- }
- },
- "unpipe": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
- "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
- },
- "utils-merge": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
- "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
- },
- "vary": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
- "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
- }
- }
-}
diff --git a/src/app/angular.json b/src/app/angular.json
index fbd6087..142a7d6 100644
--- a/src/app/angular.json
+++ b/src/app/angular.json
@@ -16,7 +16,9 @@
"outputPath": "dist/dwt-angular-advanced",
"index": "src/index.html",
"main": "src/main.ts",
- "polyfills": "src/polyfills.ts",
+ "polyfills": [
+ "zone.js"
+ ],
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
@@ -43,7 +45,6 @@
}
],
"optimization": true,
- "outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
@@ -75,62 +76,8 @@
"browserTarget": "dwt-angular-advanced:build:production"
}
}
- },
- "extract-i18n": {
- "builder": "@angular-devkit/build-angular:extract-i18n",
- "options": {
- "browserTarget": "dwt-angular-advanced:build"
- }
- },
- "test": {
- "builder": "@angular-devkit/build-angular:karma",
- "options": {
- "main": "src/test.ts",
- "polyfills": "src/polyfills.ts",
- "tsConfig": "tsconfig.spec.json",
- "karmaConfig": "karma.conf.js",
- "assets": [
- "src/favicon.ico",
- "src/assets",
- {
- "glob": "**/*",
- "input": "./node_modules/dwt/dist",
- "output": "/assets/dwt-resources/"
- }
- ],
- "styles": [
- "src/styles.css"
- ],
- "scripts": []
- }
- },
- "lint": {
- "builder": "@angular-devkit/build-angular:tslint",
- "options": {
- "tsConfig": [
- "tsconfig.app.json",
- "tsconfig.spec.json",
- "e2e/tsconfig.json"
- ],
- "exclude": [
- "**/node_modules/**"
- ]
- }
- },
- "e2e": {
- "builder": "@angular-devkit/build-angular:protractor",
- "options": {
- "protractorConfig": "e2e/protractor.conf.js",
- "devServerTarget": "dwt-angular-advanced:serve"
- },
- "configurations": {
- "production": {
- "devServerTarget": "dwt-angular-advanced:serve:production"
- }
- }
}
}
}
- },
- "defaultProject": "dwt-angular-advanced"
+ }
}
diff --git a/src/app/app.component.css b/src/app/app.component.css
index e8b73f5..3d7bcfb 100644
--- a/src/app/app.component.css
+++ b/src/app/app.component.css
@@ -331,3 +331,9 @@ table.bc-table {
.bc-table-ext tbody td, .bc-table-ext thead th {
width: 20%
}
+
+.ds-button-start-demo{
+ margin-top: 20px;
+ padding: 10px 0;
+ cursor: pointer;
+}
\ No newline at end of file
diff --git a/src/app/app.component.html b/src/app/app.component.html
index ae33e3a..a2201e8 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -24,52 +24,40 @@
{{ title }}
Dynamic Web TWAIN features image aquisition via scanners or cameras as well as image editing, uploading and
- recoginzing (barcode & OCR), etc.
+ barcode recoginzing, etc.
- Recommended environments
+ Recommended environments(*1)
-
- 1
- 2
-
-
-
-
-
≥80
≥70
- ≥443
- 113
- ≥134
- ≥80
- ≥70
- ≥134
+ ≥44(*2)
+ 11(*2)
+ ≥13(*3)
- [1] Windows7 & 10 ; macOS 10.13 ~ 10.15 ; Linux (Ubuntu 18.04, Debian 9, Fedora 32)
- [2] iOS 13 & iPadOS 13 ; Android 10 & 11
- [3] Windows only
- [4] macOS, iOS & iPadOS only
+ [*1] Windows7+; macOS 10.13+ ; Linux (Ubuntu 18.04, Debian 9, Fedora 32, etc.)
+ [*2] Windows only
+ [*3] macOS, iOS & iPadOS only
Your current environment is
{{currentEnv}}
- Start Demo
+ Start Demo
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 5081e05..80dc993 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,11 +1,19 @@
import { Component, OnInit, HostListener } from '@angular/core';
+import { CommonModule } from '@angular/common';
import { DwtService } from './dwt.service';
import { Subject } from 'rxjs';
+import { DwtComponent } from './dwt/dwt.component';
+
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
+ styleUrl: './app.component.css',
+
+ imports: [
+ CommonModule,
+ DwtComponent
+ ]
})
export class AppComponent implements OnInit {
eventsSubject: Subject = new Subject();
@@ -15,12 +23,18 @@ export class AppComponent implements OnInit {
this.eventsSubject.next(event);
}
title = 'DWT + Angular Sample';
- version = ' v18.2';
+ version = ' v19.x';
currentEnv = "";
bStartUp = true;
- bMobile = false;
+ bStartDemo = false;
bUseCameraViaDirectShow = true;
- constructor(protected dwtService: DwtService) { }
+ constructor(protected dwtService: DwtService) {
+ let _this = this;
+ dwtService.showStartDemo(function(bShowStartDemo){
+ _this.bStartDemo = bShowStartDemo;
+ //_this.onResize(undefined);
+ });
+ }
toggleStartDemo() {
this.bStartUp = !this.bStartUp;
@@ -28,21 +42,17 @@ export class AppComponent implements OnInit {
}
ngOnInit() {
let env = this.dwtService.runningEnvironment;
- if (env.bMobile) {
- this.bMobile = env.bMobile;
- this.currentEnv += env.bChrome ? "Chrome " + env.strChromeVersion : "";
- this.currentEnv += env.bFirefox ? "Firefox " + env.strFirefoxVersion : "";
- this.currentEnv += env.bSafari ? "Safari" : "";
- } else {
- this.currentEnv += env.bWin ? "Windows, " : "";
- this.currentEnv += env.bLinux ? "Linux, " : "";
- this.currentEnv += env.bChrome ? "Chrome " + env.strChromeVersion : "";
- this.currentEnv += env.bFirefox ? "Firefox " + env.strFirefoxVersion : "";
- this.currentEnv += env.bSafari ? "Safari" : "";
- this.currentEnv += env.bIE ? "Internet Explorer" + env.strIEVersion : "";
- this.currentEnv += env.bEdge ? "Edge" : "";
- }
+
+ this.currentEnv += env.bWin ? "Windows, " : "";
+ this.currentEnv += env.bLinux ? "Linux, " : "";
+ this.currentEnv += env.bChrome ? "Chrome " + env.strChromeVersion : "";
+ this.currentEnv += env.bFirefox ? "Firefox " + env.strFirefoxVersion : "";
+ this.currentEnv += env.bSafari ? "Safari" : "";
+ this.currentEnv += env.bIE ? "Internet Explorer" + env.strIEVersion : "";
+ this.currentEnv += env.bEdge ? "Edge" : "";
+
let curYear = document.getElementById("copyRightCurYear");
curYear.innerHTML = (new Date()).getFullYear().toString();
}
+
}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 490056b..e69de29 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -1,26 +0,0 @@
-import { BrowserModule } from '@angular/platform-browser';
-import { NgModule } from '@angular/core';
-
-import { AppComponent } from './app.component';
-import { DwtComponent } from './dwt/dwt.component';
-import { FormsModule } from '@angular/forms';
-import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
-import { CallbackPipe } from './callback.pipe';
-import { SafeurlPipe } from './safeurl.pipe';
-
-@NgModule({
- declarations: [
- AppComponent,
- DwtComponent,
- CallbackPipe,
- SafeurlPipe
- ],
- imports: [
- BrowserModule,
- FormsModule,
- NgbModule
- ],
- providers: [],
- bootstrap: [AppComponent]
-})
-export class AppModule { }
diff --git a/src/app/dwt.service.ts b/src/app/dwt.service.ts
index 003ed47..bf1ba15 100644
--- a/src/app/dwt.service.ts
+++ b/src/app/dwt.service.ts
@@ -6,11 +6,10 @@ import { DynamsoftEnumsDWT } from 'dwt/dist/types/Dynamsoft.Enum';
import { WebTwain } from 'dwt/dist/types/WebTwain';
import { DeviceConfiguration, ScanSetup } from 'dwt/dist/types/WebTwain.Acquire';
import { RuntimeSettings, TextResults, TextResult } from 'dwt/dist/types/Addon.BarcodeReader';
-import { OCRPro, Rect } from 'dwt/dist/types/Addon.OCRPro';
import { DWTInitialConfig } from 'dwt/dist/types/Dynamsoft';
@Injectable({
- providedIn: 'root'
+ providedIn: 'any'
})
export class DwtService {
@@ -20,8 +19,8 @@ export class DwtService {
/**
* WebTwain objects
*/
- protected _DWObject: WebTwain = null;
- protected _DWObjectEx: WebTwain = null;
+ protected _DWTObject: WebTwain = null;
+ protected _DWTObjectEx: WebTwain = null;
/**
* Global environment that is detected by the dwt library.
*/
@@ -49,105 +48,23 @@ export class DwtService {
*/
public barcodeResults = [];
public barcodeRects = { imageIds: [], rects: [] };
- /**
- * OCR
- */
- public ocrResultBase64Strings: string[] = [];
- public OCRLanguages = [
- { desc: "Arabic", val: "ara" },
- { desc: "Bengali", val: "ben" },
- { desc: "Chinese_Simplified", val: "chi_sim" },
- { desc: "Chinese_Traditional", val: "chi_tra" },
- { desc: "English", val: "eng", selected: true },
- { desc: "French", val: "fra" },
- { desc: "German", val: "deu" },
- { desc: "Hindi", val: "hin" },
- { desc: "Indonesian", val: "ind" },
- { desc: "Italian", val: "ita" },
- { desc: "Japanese", val: "jpn" },
- { desc: "Javanese", val: "jav" },
- { desc: "Korean", val: "kor" },
- { desc: "Malay", val: "msa" },
- { desc: "Marathi", val: "mar" },
- { desc: "Panjabi", val: "pan" },
- { desc: "Persian", val: "fas" },
- { desc: "Portuguese", val: "por" },
- { desc: "Russian", val: "rus" },
- { desc: "Spanish", val: "spa" },
- { desc: "Swahili", val: "swa" },
- { desc: "Tamil", val: "tam" },
- { desc: "Telugu", val: "tel" },
- { desc: "Thai", val: "tha" },
- { desc: "Turkish", val: "tur" },
- { desc: "Vietnamese", val: "vie" },
- { desc: "Urdu", val: "urd" }
- ];
- public OCROutputFormats = [
- { desc: "STRING", val: 0 },
- { desc: "Text PDF", val: 1 },
- { desc: "Image-over-text PDF", val: 2 }
- ];
- public OCRProFindTextFlags = [
- { desc: "whole word", val: Dynamsoft.DWT.EnumDWT_OCRFindTextFlags.OCRFT_WHOLEWORD },
- { desc: "match case", val: Dynamsoft.DWT.EnumDWT_OCRFindTextFlags.OCRFT_MATCHCASE },
- { desc: "fuzzy match", val: Dynamsoft.DWT.EnumDWT_OCRFindTextFlags.OCRFT_FUZZYMATCH }
- ];
- public OCRProFindTextAction = [
- { desc: "highlight", val: Dynamsoft.DWT.EnumDWT_OCRFindTextAction.OCRFT_HIGHLIGHT },
- { desc: "strikeout", val: Dynamsoft.DWT.EnumDWT_OCRFindTextAction.OCRFT_STRIKEOUT },
- { desc: "mark for redact", val: Dynamsoft.DWT.EnumDWT_OCRFindTextAction.OCRFT_MARKFORREDACT }
- ];
- public OCRProLanguages = [
- { desc: "English", val: "eng" },
- { desc: "Arabic", val: "arabic" },
- { desc: "French", val: "french" },
- { desc: "German", val: "german" },
- { desc: "Italian", val: "italian" },
- { desc: "Spanish", val: "spanish" }
- ];
- public OCRProRecognitionModule = [
- { desc: "auto", val: Dynamsoft.DWT.EnumDWT_OCRProRecognitionModule.OCRPM_AUTO },
- { desc: "most accurate", val: Dynamsoft.DWT.EnumDWT_OCRProRecognitionModule.OCRPM_MOSTACCURATE },
- { desc: "balanced", val: Dynamsoft.DWT.EnumDWT_OCRProRecognitionModule.OCRPM_BALANCED },
- { desc: "fastest", val: Dynamsoft.DWT.EnumDWT_OCRProRecognitionModule.OCRPM_FASTEST }
- ];
- public OCRProOutputFormat = [
- { desc: "STRING", val: Dynamsoft.DWT.EnumDWT_OCRProOutputFormat.OCRPFT_TXTS },
- { desc: "CSV", val: Dynamsoft.DWT.EnumDWT_OCRProOutputFormat.OCRPFT_TXTCSV },
- { desc: "Text Formatted", val: Dynamsoft.DWT.EnumDWT_OCRProOutputFormat.OCRPFT_TXTF },
- { desc: "XML", val: Dynamsoft.DWT.EnumDWT_OCRProOutputFormat.OCRPFT_XML },
- { desc: "PDF", val: Dynamsoft.DWT.EnumDWT_OCRProOutputFormat.OCRPFT_IOTPDF },
- { desc: "PDF with MRC compression", val: Dynamsoft.DWT.EnumDWT_OCRProOutputFormat.OCRPFT_IOTPDF_MRC }
- ];
- public OCRProPDFVersion = [
- { desc: "", val: "" },
- { desc: "1.0", val: Dynamsoft.DWT.EnumDWT_OCRProPDFVersion.OCRPPDFV_0 },
- { desc: "1.1", val: Dynamsoft.DWT.EnumDWT_OCRProPDFVersion.OCRPPDFV_1 },
- { desc: "1.2", val: Dynamsoft.DWT.EnumDWT_OCRProPDFVersion.OCRPPDFV_2 },
- { desc: "1.3", val: Dynamsoft.DWT.EnumDWT_OCRProPDFVersion.OCRPPDFV_3 },
- { desc: "1.4", val: Dynamsoft.DWT.EnumDWT_OCRProPDFVersion.OCRPPDFV_4 },
- { desc: "1.5", val: Dynamsoft.DWT.EnumDWT_OCRProPDFVersion.OCRPPDFV_5 },
- { desc: "1.6", val: Dynamsoft.DWT.EnumDWT_OCRProPDFVersion.OCRPPDFV_6 },
- { desc: "1.7", val: Dynamsoft.DWT.EnumDWT_OCRProPDFVersion.OCRPPDFV_7 }
- ];
- public OCRProPDFAVersion = [
- { desc: "", val: "" },
- { desc: "pdf/a-1a", val: Dynamsoft.DWT.EnumDWT_OCRProPDFAVersion.OCRPPDFAV_1A },
- { desc: "pdf/a-1b", val: Dynamsoft.DWT.EnumDWT_OCRProPDFAVersion.OCRPPDFAV_1B },
- { desc: "pdf/a-2a", val: Dynamsoft.DWT.EnumDWT_OCRProPDFAVersion.OCRPPDFAV_2A },
- { desc: "pdf/a-2b", val: Dynamsoft.DWT.EnumDWT_OCRProPDFAVersion.OCRPPDFAV_2B },
- { desc: "pdf/a-2u", val: Dynamsoft.DWT.EnumDWT_OCRProPDFAVersion.OCRPPDFAV_2U },
- { desc: "pdf/a-3a", val: Dynamsoft.DWT.EnumDWT_OCRProPDFAVersion.OCRPPDFAV_3A },
- { desc: "pdf/a-3b", val: Dynamsoft.DWT.EnumDWT_OCRProPDFAVersion.OCRPPDFAV_3B },
- { desc: "pdf/a-3u", val: Dynamsoft.DWT.EnumDWT_OCRProPDFAVersion.OCRPPDFAV_3U }
- ];
/**
* Save
*/
private fileSavingPath = "C:";
private fileActualName = "";
+ private _doFunction;
+
constructor() {
+ Dynamsoft.OnLicenseError = function (message, errorCode) {
+ if(errorCode == -2808)
+ message = 'Sorry. Your product key has expired. You can purchase a full license at the
online store .
Or, you can try requesting a new product key at
this page .
';
+ (Dynamsoft.DWT as any).ShowMessage(message, {
+ width: 680,
+ headerStyle: 2
+ });
+ };
/**
* ResourcesPath & ProductKey must be set in order to use the library!
*/
@@ -159,11 +76,21 @@ export class DwtService {
* ConnectToTheService is overwritten here for smoother install process.
*/
Dynamsoft.DWT.ConnectToTheService = () => {
- this.mountDWT();
+ //this.mountDWT();
+ this._doFunction(true);
+ window.location.reload();
};
+ Dynamsoft.DWT.OnWebTwainReady = () => {
+ this._doFunction(true);
+ }
}
+
+ showStartDemo(doFunction){
+ this._doFunction = doFunction;
+ }
+
mountDWT(UseService?: boolean): Promise {
- this._DWObject = null;
+ this._DWTObject = null;
return new Promise((res, rej) => {
let dwtInitialConfig: DWTInitialConfig = {
WebTwainId: "dwtObject"
@@ -189,14 +116,25 @@ export class DwtService {
dwtInitialConfig.UseLocalService = Dynamsoft.DWT.UseLocalService;
Dynamsoft.DWT.CreateDWTObjectEx(
dwtInitialConfig,
- (_DWObject) => {
- this._DWObject = _DWObject;
- /*this._DWObject.IfShowProgressBar = false;
- this._DWObject.IfShowCancelDialogWhenImageTransfer = false;*/
+ (_DWTObject) => {
+ this._DWTObject = _DWTObject;
+ /*this._DWTObject.IfShowProgressBar = false;
+ this._DWTObject.IfShowCancelDialogWhenImageTransfer = false;*/
+
+ // from v19.0
+ this._DWTObject.Addon.PDF.SetReaderOptions({
+ convertMode: Dynamsoft.DWT.EnumDWT_ConvertMode.CM_RENDERALL,
+ renderOptions: {
+ renderAnnotations: true,
+ resolution: 200
+ },
+ preserveUnmodifiedOnSave: true
+ });
+
/**
* The event OnBufferChanged is used here for monitoring the image buffer.
*/
- this._DWObject.RegisterEvent("OnBufferChanged", (changedIndexArray, operationType, changedIndex, imagesCount) => {
+ this._DWTObject.RegisterEvent("OnBufferChanged", (changedIndexArray, operationType, changedIndex, imagesCount) => {
switch (operationType) {
/** reserved space
* type: 1-Append(after index), 2-Insert(before index), 3-Remove, 4-Edit(Replace), 5-Index Change
@@ -209,12 +147,12 @@ export class DwtService {
default: break;
}
this.bufferSubject.next("changed");
- if (this._DWObject.HowManyImagesInBuffer === 0)
+ if (this._DWTObject.HowManyImagesInBuffer === 0)
this.bufferSubject.next("empty");
else
this.bufferSubject.next("filled");
});
- res(_DWObject);
+ res(_DWTObject);
},
(errorString) => {
rej(errorString);
@@ -233,20 +171,20 @@ export class DwtService {
});
}
/**
- * Create an extra WebTwain instance _DWObjectEx
+ * Create an extra WebTwain instance _DWTObjectEx
* This is used solely for displaying & capturing from a video stream.
*/
mountVideoContainer(): Promise {
- this._DWObjectEx = null;
+ this._DWTObjectEx = null;
return new Promise((res, rej) => {
- if (this._DWObject) {
+ if (this._DWTObject) {
let dwtInitialConfig: DWTInitialConfig = {
WebTwainId: "videoContainer"
};
Dynamsoft.DWT.CreateDWTObjectEx(
dwtInitialConfig,
(_container) => {
- this._DWObjectEx = _container;
+ this._DWTObjectEx = _container;
res(_container);
},
(errorString) => {
@@ -274,11 +212,11 @@ export class DwtService {
*/
getDevices(bfromCamera): Promise {
return new Promise((res, rej) => {
- let _dwt = this._DWObject;
- if (this._DWObjectEx)
- _dwt = this._DWObjectEx;
+ let _dwt = this._DWTObject;
+ if (this._DWTObjectEx)
+ _dwt = this._DWTObjectEx;
this.devices = [];
- this._DWObject.GetDevicesAsync().then((devicesList)=>{
+ this._DWTObject.GetDevicesAsync().then((devicesList)=>{
for (let i = 0; i < devicesList.length; i++) {
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] });
}
@@ -311,7 +249,7 @@ export class DwtService {
* Retrieve detailed information of the devices.
*/
getDeviceDetails() {
- return this._DWObject.GetSourceNames(true);
+ return this._DWTObject.GetSourceNames(true);
}
/**
* Select a scanner or camera by name.
@@ -327,9 +265,9 @@ export class DwtService {
this.devices.forEach((value, index) => {
if (value && value.name === name) {
if (index > this._scannersCount - 1) {
- let _dwt = this._DWObject;
- if (this._DWObjectEx)
- _dwt = this._DWObjectEx;
+ let _dwt = this._DWTObject;
+ if (this._DWTObjectEx)
+ _dwt = this._DWTObjectEx;
if (this.bUseCameraViaDirectShow) {
_dwt.Addon.Webcam.StopVideo();
if (_dwt.Addon.Webcam.SelectSource(value.label)) {
@@ -347,7 +285,7 @@ export class DwtService {
}
else {
waitForAnotherPromise = true;
- this._DWObject.SelectDeviceAsync(value.deviceInfo).then(()=>{
+ this._DWTObject.SelectDeviceAsync(value.deviceInfo).then(()=>{
this._selectedDevice = name;
this.generalSubject.next({ type: "deviceName", deviceName: this._selectedDevice });
res(true);
@@ -358,12 +296,8 @@ export class DwtService {
}
});
if (!waitForAnotherPromise) {
- if (this._selectedDevice !== "") {
- this.generalSubject.next({ type: "deviceName", deviceName: this._selectedDevice });
- res(true);
- }
- else
- res(false);
+ this.generalSubject.next({ type: "deviceName", deviceName: this._selectedDevice });
+ res(true);
}
});
}
@@ -440,12 +374,12 @@ export class DwtService {
return new Promise((res, rej) => {
if (this._selectedDevice !== "") {
if (this._useCamera) {
- if (this._DWObjectEx) {
+ if (this._DWTObjectEx) {
if (this.bUseCameraViaDirectShow) {
- this._DWObjectEx.Addon.Webcam.CaptureImage(() => {
- this.getBlob([0], Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG, this._DWObjectEx)
- .then(blob => this._DWObject.LoadImageFromBinary(blob, () => {
- this._DWObjectEx.RemoveImage(0);
+ this._DWTObjectEx.Addon.Webcam.CaptureImage(() => {
+ this.getBlob([0], Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG, this._DWTObjectEx)
+ .then(blob => this._DWTObject.LoadImageFromBinary(blob, () => {
+ this._DWTObjectEx.RemoveImage(0);
res(true);
}, (errCode, errString) => rej(errString)));
}, (errCode, errStr) => rej(errStr));
@@ -454,18 +388,18 @@ export class DwtService {
rej("No WebTwain instanance for camera capture!");
}
} else {
- this._DWObject.SetOpenSourceTimeout(3000);
+ this._DWTObject.SetOpenSourceTimeout(3000);
if (bAdvanced) {
- if (this._DWObject.OpenSource()){
- this._DWObject.startScan(config);
+ if (this._DWTObject.OpenSource()){
+ this._DWTObject.startScan(config);
} else {
- rej(this._DWObject.ErrorString);
+ rej(this._DWTObject.ErrorString);
}
} else {
- this._DWObject.AcquireImageAsync(config).then(()=>{
- return this._DWObject.CloseSourceAsync();
+ this._DWTObject.AcquireImageAsync(config).then(()=>{
+ return this._DWTObject.CloseSourceAsync();
}).then(()=>{
- this._DWObject.CloseWorkingProcess();
+ this._DWTObject.CloseWorkingProcess();
}).catch((exp) =>{
rej(exp.message);
});
@@ -482,15 +416,13 @@ export class DwtService {
*/
load(files?: FileList): Promise {
return new Promise((res, rej) => {
- this._DWObject.Addon.PDF.SetConvertMode(Dynamsoft.DWT.EnumDWT_ConvertMode.CM_AUTO);
- this._DWObject.Addon.PDF.SetResolution(200);
- this._DWObject.IfShowFileDialog = true;
- this._DWObject.RegisterEvent("OnPostLoad", (
+ this._DWTObject.IfShowFileDialog = true;
+ this._DWTObject.RegisterEvent("OnPostLoad", (
directory: string,
fileName: string,
fileType: DynamsoftEnumsDWT.EnumDWT_ImageType) => {
});
- this._DWObject.LoadImageEx("", -1, () => { res(true); }, (errCode, errStr) => rej(errStr))
+ this._DWTObject.LoadImageEx("", -1, () => { res(true); }, (errCode, errStr) => rej(errStr))
});
}
/**
@@ -512,26 +444,26 @@ export class DwtService {
* @param config Configuration for the read.
*/
readBarcode(config?: any) {
- let _index = this._DWObject.CurrentImageIndexInBuffer;
+ let _index = this._DWTObject.CurrentImageIndexInBuffer;
if (config && config.index !== undefined) {
_index = Math.floor(config.index);
- if (_index < 0 || _index > this._DWObject.HowManyImagesInBuffer - 1)
- _index = this._DWObject.CurrentImageIndexInBuffer;
+ if (_index < 0 || _index > this._DWTObject.HowManyImagesInBuffer - 1)
+ _index = this._DWTObject.CurrentImageIndexInBuffer;
}
Dynamsoft.Lib.showMask();
- this._DWObject.Addon.BarcodeReader.getRuntimeSettings()
+ this._DWTObject.Addon.BarcodeReader.getRuntimeSettings()
.then(settings => {
- if (this._DWObject.GetImageBitDepth(_index) === 1) {
+ if (this._DWTObject.GetImageBitDepth(_index) === 1) {
settings.scaleDownThreshold = 214748347;
} else {
settings.scaleDownThreshold = 2300;
}
settings.barcodeFormatIds = Dynamsoft.DBR.EnumBarcodeFormat.BF_ALL;
if (config) {
- if (config.formatId) {
+ if ('formatId' in config) {
settings.barcodeFormatIds = config.formatId;
}
- if (config.formatId2) {
+ if ('formatId2' in config) {
settings.barcodeFormatIds_2 = config.formatId2;
}
if (config.zones)
@@ -541,6 +473,8 @@ export class DwtService {
this.barcodeResults = [];
settings.region.regionMeasuredByPercentage = 0;
+ this._DWTObject.Viewer.fitWindow();
+
if (config && config.zones && config.zones.length > 0) {
let i = 0;
let readBarcodeFromRect = () => {
@@ -593,9 +527,10 @@ export class DwtService {
}
resultString.push({ text: "--------------------------", type: "seperator" });
resultString.push({ text: "Total barcode(s) found: " + allBarcodeResults.length, type: "important" });
+ resultString.push({ text: "--------------------------", type: "seperator" });
for (let i = 0; i < allBarcodeResults.length; ++i) {
let result: TextResult = allBarcodeResults[i];
- resultString.push({ text: "------------------", type: "seperator" });
+ if(i>0) resultString.push({ text: "------------------", type: "seperator" });
resultString.push({ text: "Barcode " + (i + 1).toString(), type: "nomral" });
resultString.push({ text: "Type: " + (result.barcodeFormatString ? result.barcodeFormatString : result.barcodeFormatString_2), type: "nomral" });
resultString.push({ text: "Value: " + result.barcodeText, type: "important" });
@@ -606,11 +541,11 @@ export class DwtService {
this.barcodeSubject.next({ done: true });
Dynamsoft.Lib.hideMask();
};
- this._DWObject.Addon.BarcodeReader.updateRuntimeSettings(settings)
+ this._DWTObject.Addon.BarcodeReader.updateRuntimeSettings(settings)
.then(_ => {
let decoderFunc = () => {
try {
- this._DWObject.Addon.BarcodeReader.decode(index)
+ this._DWTObject.Addon.BarcodeReader.decode(index)
.then(textResults => {
this.barcodeResults.push(textResults);
bHasCallback ? callback() : outputResults();
@@ -657,210 +592,7 @@ export class DwtService {
}
this.barcodeSubject.next(this.barcodeRects);
}
- /**
- * loadOCRModule & downloadOCRBasic prepare resources for the OCR module.
- */
- loadOCRModule(engine: string): Promise {
- return new Promise((res, rej) => {
- if (Dynamsoft.Lib.product.bHTML5Edition) {
- if (engine === "Pro") {
- if (this._DWObject.Addon.OCRPro.IsModuleInstalled()) {
- res(true);
- } else {
- this.downloadOCRPro()
- .then(
- success =>
- res(success),
- error =>
- rej(error)
- );
- }
- } else {
- if (this._DWObject.Addon.OCR.IsModuleInstalled()) {
- this.downloadOCRBasic(false)
- .then(
- success =>
- res(success),
- error =>
- rej(error)
- );
- } else {
- this.downloadOCRBasic(true)
- .then(
- success =>
- res(success),
- error =>
- rej(error)
- );
- }
- }
- }
- else {
- rej("OCR not supported in this environment!");
- }
- });
- }
- downloadOCRBasic(bDownloadDLL: boolean, langPath?: string): Promise {
- return new Promise((res, rej) => {
- let strOCRPath = Dynamsoft.DWT.ResourcesPath + "/addon/OCRx64.zip";
- let strOCRLangPath = Dynamsoft.DWT.ResourcesPath + '/addon/OCRBasicLanguages/English.zip';
- if (langPath)
- strOCRLangPath = langPath;
- if (bDownloadDLL) {
- this._DWObject.Addon.OCR.Download(
- strOCRPath,
- () => this.downloadOCRBasic(false).then(() => res(true)).catch(err=>rej(err)),
- (errorCode, errorString) => rej(errorString)
- );
- } else {
- this._DWObject.Addon.OCR.DownloadLangData(
- strOCRLangPath,
- () => res(true),
- (errorCode, errorString) => rej(errorString)
- );
- }
- });
- }
- downloadOCRPro(): Promise {
- return new Promise((res, rej) => {
- let strOCRPath = "https://tst.dynamsoft.com/libs/ocrp/OCRProx64.zip";
- this._DWObject.Addon.OCRPro.Download(
- strOCRPath,
- () => res(true),
- (errorCode, errorString) => rej(errorString)
- );
- });
- }
- /**
- * Prepararation for the OCR.
- * @param language The target language.
- * @param outputFormat The output format.
- * @param zones Zones to read.
- */
- ocr(ocrOptions: OCROptions | OCRProOptions, zones?: Zone[]): Promise {
- let _index = this._DWObject.CurrentImageIndexInBuffer;
- if (zones) zones = this.filterZones(_index, zones);
- if (ocrOptions.engine === "basic") {
- let language: DynamsoftEnumsDWT.EnumDWT_OCRLanguage = ocrOptions.Language;
- let outputFormat: DynamsoftEnumsDWT.EnumDWT_OCROutputFormat = parseInt(ocrOptions.OutputFormat);
- return new Promise((res, rej) => {
- this._DWObject.Addon.OCR.SetLanguage(language);
- this._DWObject.Addon.OCR.SetOutputFormat(outputFormat);
- let strOCRLangPath = Dynamsoft.DWT.ResourcesPath + '/addon/OCRBasicLanguages/English.zip';
- for (let i = 0; i < this.OCRLanguages.length; i++) {
- if (this.OCRLanguages[i].val === language) {
- strOCRLangPath = Dynamsoft.DWT.ResourcesPath + '/addon/OCRBasicLanguages/' + this.OCRLanguages[i].desc + '.zip';
- }
- }
- this.downloadOCRBasic(false)
- .then(
- () => {
- this.ocrResultBase64Strings = [];
- let i = 0;
- if (zones !== undefined && zones.length > 0) {
- let ocrCallback = (hasError: boolean, errStr?: string) => {
- if (hasError) {
- rej(errStr);
- } else {
- if (i === zones.length) {
- res(this.processOCRResult());
- } else {
- this.doOCR(_index, zones[i], ocrCallback);
- i++;
- }
- }
- };
- ocrCallback(false);
- } else
- this.doOCR(_index, null, (hasError: boolean, errStr?: string) => {
- if (hasError) {
- rej(errStr);
- } else
- res(this.processOCRResult());
- });
- },
- err => rej(err)
- );
- });
- } else {
- return new Promise((res, rej) => {
- let settings = Dynamsoft.WebTwain.Addon.OCRPro.NewSettings();
- settings.Languages = ocrOptions.Language;
- settings.RecognitionModule = (ocrOptions).RecognitionModule;
- settings.OutputFormat = (ocrOptions).OutputFormat;
- if ((ocrOptions).OutputFormat === Dynamsoft.DWT.EnumDWT_OCRProOutputFormat.OCRPFT_IOTPDF ||
- (ocrOptions).OutputFormat === Dynamsoft.DWT.EnumDWT_OCRProOutputFormat.OCRPFT_IOTPDF_MRC) {
- settings.PDFVersion = (ocrOptions).PDFVersion;
- settings.PDFAVersion = (ocrOptions).PDFAVersion;
- }
- if ((ocrOptions).bFindText) {
- settings.Redaction.FindText = (ocrOptions).textToFind;
- settings.Redaction.FindTextFlags = (ocrOptions).FindTextFlags;
- settings.Redaction.FindTextAction = (ocrOptions).FindTextAction;
- }
- //settings.LicenseChecker =
- this._DWObject.Addon.OCRPro.Settings = settings;
- this.ocrResultBase64Strings = [];
- if (zones !== undefined && zones.length > 0) {
- let rects: Rect[] = [];
- for (let i = 0; i < zones.length; i++) {
- rects.push({ left: zones[i].x, right: zones[i].x + zones[i].width, top: zones[i].y, bottom: zones[i].y + zones[i].height });
- }
- this._DWObject.Addon.OCRPro.RecognizeRect(_index, rects, (_index, aryZone, result) => {
- this.ocrResultBase64Strings.push(result.Get());
- res(this.processOCRResult());
- }, (errCode, errString) => rej(errString)
- );
- }
- else {
- this._DWObject.Addon.OCRPro.Recognize(_index, (_index, result) => {
- this.ocrResultBase64Strings.push(result.Get());
- res(this.processOCRResult());
- }, (errCode, errString) => rej(errString)
- );
- }
- });
- }
- }
- /**
- * Actual OCR.
- * @param index Specify the image to read.
- * @param zone Specify a Zone.
- * @param callback Callback after the read.
- */
- doOCR(index: number, zone?: any, callback?: (...args) => void): any {
- if (!!zone && !!callback) {
- this._DWObject.Addon.OCR.RecognizeRect(
- index, zone.x, zone.y, zone.x + zone.width, zone.y + zone.height, (imageId, left, top, right, bottom, result) => {
- this.ocrResultBase64Strings.push(result.Get());
- callback(false);
- }, (errCode, errString) => callback(true, errString));
- } else if (this._DWObject.SelectedImagesIndices.length > 1) {
- this._DWObject.Addon.OCR.RecognizeSelectedImages((result) => {
- this.ocrResultBase64Strings.push(result.Get());
- callback(false);
- }, (errCode, errString) => callback(true, errString));
- }
- else {
- this._DWObject.Addon.OCR.Recognize(index,
- (imageId, result) => {
- this.ocrResultBase64Strings.push(result.Get());
- callback(false);
- }, (errCode, errString) => callback(true, errString));
- }
- }
- /**
- * Process OCR result.
- */
- processOCRResult(): Promise {
- return new Promise((res, rej) => {
- if (this.ocrResultBase64Strings.length === 0)
- rej("No text found!");
- else {
- res(this.ocrResultBase64Strings.join(","));
- }
- });
- }
+
/**
* Convert image(s) to a Blob.
* @param indices Specify the image(s).
@@ -869,7 +601,7 @@ export class DwtService {
*/
getBlob(indices: number[], type: DynamsoftEnumsDWT.EnumDWT_ImageType, dwt?: WebTwain): Promise {
return new Promise((res, rej) => {
- let _dwt = this._DWObject;
+ let _dwt = this._DWTObject;
if (dwt)
_dwt = dwt;
switch (type) {
@@ -891,7 +623,7 @@ export class DwtService {
*/
getBase64(indices: number[], type: DynamsoftEnumsDWT.EnumDWT_ImageType, dwt?: WebTwain): Promise {
return new Promise((res, rej) => {
- let _dwt = this._DWObject;
+ let _dwt = this._DWTObject;
if (dwt)
_dwt = dwt;
if (type === Dynamsoft.DWT.EnumDWT_ImageType.IT_ALL)
@@ -979,13 +711,13 @@ export class DwtService {
res({ name: _name, path: _path });
}, f = (errCode, errStr) => rej(errStr);
switch (_type) {
- case 0: this._DWObject.SaveAsBMP(_path, indices[0], s, f); break;
- case 1: this._DWObject.SaveAsJPEG(_path, indices[0], s, f); break;
- case 2: this._DWObject.SaveAsTIFF(_path, indices[0], s, f); break;
- case 3: this._DWObject.SaveAsPNG(_path, indices[0], s, f); break;
- case 4: this._DWObject.SaveAsPDF(_path, indices[0], s, f); break;
- case 7: this._DWObject.SaveSelectedImagesAsMultiPagePDF(_path, s, f); break;
- case 8: this._DWObject.SaveSelectedImagesAsMultiPageTIFF(_path, s, f); break;
+ case 0: this._DWTObject.SaveAsBMP(_path, indices[0], s, f); break;
+ case 1: this._DWTObject.SaveAsJPEG(_path, indices[0], s, f); break;
+ case 2: this._DWTObject.SaveAsTIFF(_path, indices[0], s, f); break;
+ case 3: this._DWTObject.SaveAsPNG(_path, indices[0], s, f); break;
+ case 4: this._DWTObject.SaveAsPDF(_path, indices[0], s, f); break;
+ case 7: this._DWTObject.SaveSelectedImagesAsMultiPagePDF(_path, s, f); break;
+ case 8: this._DWTObject.SaveSelectedImagesAsMultiPageTIFF(_path, s, f); break;
default: break;
}
});
@@ -995,8 +727,8 @@ export class DwtService {
if (showDialog) {
this.fileSavingPath = "";
this.fileActualName = "";
- this._DWObject.IfShowFileDialog = false;
- this._DWObject.RegisterEvent("OnGetFilePath", (isSave, filesCount, index, directory, _fn) => {
+ this._DWTObject.IfShowFileDialog = false;
+ this._DWTObject.RegisterEvent("OnGetFilePath", (isSave, filesCount, index, directory, _fn) => {
if(isSave && filesCount != -1){
if (directory === "" && _fn === "") {
rej("User cancelled the operation.")
@@ -1009,7 +741,7 @@ export class DwtService {
});
if(this.runningEnvironment.bMac)
- this._DWObject.ShowFileDialog(
+ this._DWTObject.ShowFileDialog(
true,
"TIF,TIFF,JPG,JPEG,PNG,PDF",
0,
@@ -1020,7 +752,7 @@ export class DwtService {
0
);
else
- this._DWObject.ShowFileDialog(
+ this._DWTObject.ShowFileDialog(
true,
"BMP,TIF,JPG,PNG,PDF|*.bmp;*.tif;*.png;*.jpg;*.pdf;*.tiff;*.jpeg",
0,
@@ -1032,7 +764,7 @@ export class DwtService {
);
} else {
- this._DWObject.IfShowFileDialog = false;
+ this._DWTObject.IfShowFileDialog = false;
res(saveInner(filePath, fileName, type));
}
});
@@ -1065,7 +797,7 @@ export class DwtService {
savedDir = protocol + window.location.hostname + ":" + _strPort + "/uploaded/";
url = protocol + window.location.hostname + ":" + _strPort + strActionPage;
}
- this._DWObject.HTTPUpload(
+ this._DWTObject.HTTPUpload(
url,
indices,
type,
@@ -1099,22 +831,3 @@ interface Zone {
height: number;
index: number;
}
-
-interface OCROptions {
- engine: string;
- Language: string;
- OutputFormat: string;
-};
-
-interface OCRProOptions {
- engine: string;
- Language: string;
- OutputFormat: string;
- bFindText: boolean;
- textToFind: string;
- FindTextFlags: number;
- FindTextAction: number;
- RecognitionModule: string;
- PDFVersion: string;
- PDFAVersion: string;
-};
diff --git a/src/app/dwt/dwt.component.css b/src/app/dwt/dwt.component.css
index 78f0ab4..a9d56eb 100644
--- a/src/app/dwt/dwt.component.css
+++ b/src/app/dwt/dwt.component.css
@@ -2,6 +2,10 @@
border: 0;
}
+.list-group {
+ list-style:none;
+}
+
.mainContent {
width: 100vw;
max-width: 800px;
@@ -60,12 +64,6 @@ button.barcode {
background-position: center;
}
-button.ocr {
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAIAAAADnC86AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGkSURBVFhH7ZivT8NAFMfvMOvUJka2GUCRmmaiWQIKgyPB1SAQOCQh8A/gQJDgMQjE5qanFhJIWrMg+QNaaAWy7njXvi60u5Tr+mOCftJs32/F++5d37rrKGOMrIMNfK+cOrgyxMPlOI5pmr7vo8+HoijD4bDX66EPgeBlJpOJ67pocgOloCCaCPFSQ6+dTgdNbqDU8uLVU10Z4mBVVVGVhjhY0zRUpbG2pc7y62Q+sJcb1EKUNj3/QB1nPB4bhoEmIEvHSpu/aqf0wqVnVnAqbhut4JQUqcFvdyhCGjyY7h6HLkZrm2wdkNYOWgnSgtnrbSwbqncHPEAE/0BKjo7Z/ebi4PZ3dndAT6aol4E1P3pELcHf1zjZd0FIDVeGyZdGInjviu5foy6OZDD/bkQH9+WkAqkdl5YKpAWXlwpIDVcS/5u9P6H+mpOFzsIqwez5EO7baD7nbHq5Snaw80oCu0xUBTEajVBFiDuezWaoSmOla1wEdXBliIPhacfzPDS5gVJQEE2EeM9l27ZlWUU9tDWbTV3X+/0++oD6r4jK+G/BhPwAPeVgElUj/BYAAAAASUVORK5CYII=);
- background-repeat: no-repeat;
- background-position: center;
-}
-
button.save {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3hpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NTc3MiwgMjAxNC8wMS8xMy0xOTo0NDowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDo0YzVmZjRkMi1kYjVmLTQ2NjAtYmUzNS05NGEwNTlhYmRmY2QiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6Q0E5QTJGQUIyQjVGMTFFNDg4QzlFMEU1RTZGNTQ3NzYiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6Q0E5QTJGQUEyQjVGMTFFNDg4QzlFMEU1RTZGNTQ3NzYiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTQgKE1hY2ludG9zaCkiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpkOTAyNGZiZS1jZDYyLTQzNjQtYjVjOS1mMjI1OTRlZGMxYzEiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NGM1ZmY0ZDItZGI1Zi00NjYwLWJlMzUtOTRhMDU5YWJkZmNkIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+nt6kZQAABoRJREFUeNrEV0tsVVUUXffcz3vlU6gEWmirNURMjBqBQKm0pZTyqZ8QJw7EiIQEB+jMgTFqP4CCTnWmwWh0oANjYlJNcGAiaXm0YIxDCBr5tK9Y2tLSvvt1733OLX39KVFCm/Pu551z9tprr733eVaSJLiXfw5/WJbFF29lR1chihlQgoguYQzE/9GAzUPREBMW3VsYbGvN0IPPzjtmnhj/4fAexEkMnlsgBHXl9v/iZfdAhAwhYNeUpbAbXYUURApgcRTHyFgxHv/kAlzbxs77s/hqbwUGRyZpoSWszAwXM6dfJbOf6abEs9E3bOHZD3/CouqHsbHcxQvrXERBQWwyAGX2cvkjoEVLsx7i747DdW3Z8FxvDufP9WIgP4D8QD8GaPTTsBRtTt/l8/qdRaD7+vRzf/81clUxIrDf2eVlSHJfI+M4FNopJ9wpDRh/KOYJTVIIsiVwbI2tdstW2ASGWUiIJWYh9bLuyXoBGSfa47o680z7xDRXqQSKVFRyXwUiz5X4R0kstopEaOyjEJAoLKKu5jG58jvbsfHBe0fIY4X6xibZnI2xVrY2NOHEsTZs294i4Pj5+NE2NDbtQBgG2N7YSFtE5GoCd1WNsBFEyewsMPblS4oQFm3YScgjMAe9uW607GpFVXU1oqiYgWtXLmP/gUNYU1mF3JlumfvywVfE+/LyClYNMcJORSh5aD0UgY4izA1ANBDzZH6ZSPqwsU21dcIC60qcp49ENJlo7dE9G9xUu4UoVuJIFHEIQpYAmEjZk24oAtM1MJuBAqFzKV0czlt6w/Hk/D1+pJ0WW2hoaia7cSr6KSb4Wr+NwnG0nUJF8xqbEVAImuobBISj9J58H8TTFTCDARYIT5bCQVdGz9QeOHhIDFWsrsTZMz20kcKaqmpiIyL6K5Hr6aFwXMF+msdxptcor6ggSyTEJAWgxIl4RmkrAuDTQmabvWYQTPdmCgELUHyl502ba6F0WSOaIaLcTPSz56ZcSKj4S0v+9Z4pA+G8GrCMCMmYTa4LA5aSuB3reAfNO3YhItcaSNnvdrZLRWukkESRfsdztrfskuyQOkQAmrY1Uioq2dNVOpyc6tNjUKSBkL7jiWx0aCIS5C7t197ZOS3mQFt7u3jDDKRabDNz0nks4PxYCFv21GHgEET4Jw0QTBbg7zdDnL4ygXH/dkNKS7FpXjASFATT38EUb1b/kgx5b2sGlDJFaz4AHB/X0hrg6P2a9/HE6izutGFb0PFmJn+5OomsbZg1upkXANPjmFjxNXd1DH+M+Tr/oTfkzU0xXPDv6oiPa5MJPNqshBWI2yGYH0CskUoGkIG1K7K4frMgZwOwIFWq/hgLHWR4Vg2tHer3kXW0Qzzblr6xEIBEFyK2E5sis2O1wp5HVyIsBEULs9Q1Jyf9Oczr8uhkXHz/2yA+vaTZFGP2AgAsw4BjsoDBcLya1i3HnwOjGJ0I4HkeHGqp7H0UTtAI52SCw1xa4srajy8Mw1N6/1EqtXVVK2C57twMJCZllKnh3EgsRkJ5/GD1Krz0XKs+vWQ8uTY/87xcd7Y+XQSgtHQpbtwck7UZOpR4jpXWKAllDDWfCKkA2aZ6sV1L9+809p990yXdTNhCCM/kB58dS1y96QR5uWyxjZFxvTaIQhqUjvS99IKIa0M8DwPct5UGEJncTkzec30/vG8vHnhkw9T8N95qw9me0/jx1Cnse3Efqqg/BIQmwu21rinjsi+/ixeoA3GspGnwUg6BHIooLmYPfPTFt1QrYqLU9IYooD5QK2PSDzRopUQDyqxN53Io5CBTVLAwLRginpiQJtI40trNNY0bDevm/WMd+PLzk7h48YIYD0iEBd/Hz9059Padx+DgdQz9dV3Ey2t4rec6MnInTyDjOrOKmjMzgRwNXcTCvYCFqAwFr73+pm42coClbLHp/ESUrt+wkbQR6u7IGRJD1lhWPJWCCH25jxcCwIQIZbTJxfwQHVDKBABvzuD8wJ8qgWEQFPWHmY7wGosodI3PLa92UFg5t9XcAFjxHrm8NKM3XbvEwa3JUYwM27gVWihbXoqalYv/VS8YIzfHR0eQUCoty5bpwmUKnEcnbDVNBxYbI3XyrHUVnV098ZSHPsbo/OSREqX22+6ddSRzXmQdeekJyzhK58Oxy28/tZZs51MAXFlW0aikseQu/x5laDdoXCLbwykA+X1ofi65uPt/3ETGyXZg3euf538LMAC3T/4HUBNiLQAAAABJRU5ErkJggg==);
background-repeat: no-repeat;
@@ -145,18 +143,6 @@ button.save {
align-items: center;
}
-.ocrResultString {
- overflow: auto;
- padding: 1vmin;
- margin: 1vh;
- height: auto;
- font-size: 12px;
- line-height: 20px;
- border: 1px solid #ccc;
- background: #e7f2fd;
- color: #606060;
-}
-
.half {
width: 50%;
}
diff --git a/src/app/dwt/dwt.component.html b/src/app/dwt/dwt.component.html
index 0c62110..316757a 100644
--- a/src/app/dwt/dwt.component.html
+++ b/src/app/dwt/dwt.component.html
@@ -1,6 +1,5 @@
-
-
-
+
+
0"
[ngStyle]="{'position':'absolute', 'left':mainViewerPos.x + 'px','top':mainViewerPos.y +'px'}">
@@ -25,18 +24,16 @@
-
-
@@ -46,23 +43,23 @@
Scan A Document
Device
- Choose...
- {{device.name}}
+ Choose...
+ {{device.name}}
- Show
+ Show
UI
AutoFeeder
+ aria-label="Checkbox for ADF" /> AutoFeeder
Duplex
+ aria-label="Checkbox for Duplex" /> Duplex
@@ -70,15 +67,15 @@ Scan A Document
B&W
+ aria-label="Radio button for BW" /> B&W
Gray
+ aria-label="Radio button for Gray" /> Gray
Color
+ aria-label="Radio button for RGB" /> Color
@@ -86,7 +83,7 @@ Scan A Document
Resolution
- Choose...
+ Choose...
100
150
200
@@ -107,12 +104,12 @@ Scan A Document
Load
-
@@ -123,7 +120,7 @@
Capture from a Camera
Choose...
- {{device.name}}
+ {{device.name}}
@@ -132,10 +129,10 @@ Capture from a Camera
0 && bUseCameraViaDirectShow" class="list-group-item">
- {{cameraOption.name}}
+ {{cameraOption.name}}
- {{item.value}}
+ {{item.value}}
{{rangePicker.title}} (Capture from a Camera
Capture
-
-
-
-
-
- Module
-
- Choose...
- Basic
- Pro
-
-
-
-
-
- {{language.desc}}
-
-
-
- {{outputFormat.desc}}
-
-
-
-
- Recognition Module
-
-
- {{recognitionModule.desc}}
-
-
-
- Target Language
-
- {{language.desc}}
-
-
-
-
- Output Format
-
-
- {{outputFormat.desc}}
-
-
-
- PDF Version
-
-
- {{pdfV.desc}}
-
-
-
- PDFA Version
-
-
- {{pdfaV.desc}}
-
-
-
-
- Search Text and Redact
-
-
- Text to Find
-
-
-
- Find Text Mode
-
-
- {{flag.desc}}
-
-
-
- Find Text Action
-
-
- {{action.desc}}
-
-
-
-
- {{ocrResultString}}
- 0">
-
- {{ocrResultFiles[i].name}}
-
-
- {{instantError}}
-
-
-
@@ -394,9 +280,9 @@
{{saveOptions.buttonText}}
Type:
- File
- Blob
- Base64
+ File
+ Blob
+ Base64
@@ -405,11 +291,11 @@ {{saveOptions.buttonText}}
Format:
- BMP
- JPG
- TIF
- PNG
- PDF
+ BMP
+ JPG
+ TIF
+ PNG
+ PDF
@@ -423,14 +309,14 @@ {{saveOptions.buttonText}}
Upload To
+ (ngModelChange)="outPutTypeChanged('File')" /> Upload To
Server
Multi-Page
+ aria-label="Checkbox for multiPage" /> Multi-Page
0 && (saveOptions.outPutFormat === 'TIF' || saveOptions.outPutFormat === 'PDF')"
@@ -438,7 +324,7 @@ {{saveOptions.buttonText}}
{{index.number+1}}
+ aria-label="Checkbox for targetIndices" /> {{index.number+1}}
0 ||saveResults.uploadedFiles.length>0 ||saveResults.blobURL.length>0||saveResults.base64String.length>0">
diff --git a/src/app/dwt/dwt.component.ts b/src/app/dwt/dwt.component.ts
index eb4dcbc..aab9f02 100644
--- a/src/app/dwt/dwt.component.ts
+++ b/src/app/dwt/dwt.component.ts
@@ -1,18 +1,31 @@
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
+
import { DwtService, Device } from './../dwt.service';
import { WebTwain } from 'dwt/dist/types/WebTwain';
import { ThumbnailViewer } from 'dwt/dist/types/WebTwain.Viewer';
import { ThumbnailViewerSettings } from 'dwt/dist/types/WebTwain.Viewer';
import { ViewMode } from 'dwt/dist/types/WebTwain.Viewer';
-import { ViewerEvent } from 'dwt/dist/types/WebTwain.Viewer';
-import { Subscription, Observable, empty } from 'rxjs';
+import { Subscription, Observable } from 'rxjs';
+
import Dynamsoft from 'dwt';
-import { NgbModal, NgbModalRef, } from '@ng-bootstrap/ng-bootstrap';
+import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
+import { CallbackPipe } from '../callback.pipe';
+import { SafeurlPipe } from '../safeurl.pipe';
@Component({
selector: 'app-dwt',
templateUrl: './dwt.component.html',
- styleUrls: ['./dwt.component.css']
+ styleUrl: './dwt.component.css',
+ imports: [
+ NgbModule,
+ CommonModule,
+ FormsModule,
+ CallbackPipe,
+ SafeurlPipe
+ ]
})
export class DwtComponent implements OnInit, OnDestroy {
@Input() events: Observable;
@@ -32,14 +45,13 @@ export class DwtComponent implements OnInit, OnDestroy {
/**
* Two WebTwain objects doing all the job.
*/
- protected DWObject: WebTwain = null;
+ protected DWTObject: WebTwain = null;
protected VideoContainer: WebTwain = null;
/**
* Global variables and status flags.
*/
public bWin = true;
- public dwtMounted = false;
- public bMobile: boolean;
+ public dwtMounted = true;
public bUseCameraViaDirectShow: boolean;
public containerId = "dwtcontrolContainer";
public videoContainerId = "videoContainer";
@@ -57,16 +69,6 @@ export class DwtComponent implements OnInit, OnDestroy {
public outputMessages: Message[] = [];
public historyMessages: Message[] = [];
public bDontScrollMessages: boolean = true;
- /**
- * For OCR.
- */
- public ocrReady: boolean = false;
- public useOCRPro: boolean = false;
- public bLoadingOCREngine: boolean = false;
- public ocrResultString: string = "";
- public ocrResultFiles: File[] = [];
- public ocrResultURLs: string[] = [];
- public ocrButtonText = "Recognize";
/**
* For Barcode Reading.
*/
@@ -104,7 +106,7 @@ export class DwtComponent implements OnInit, OnDestroy {
public currentOptionItems = [];
public currentItem = "";
public showRangePicker = false;
- public rangePicker = null;
+ public rangePicker: any = null;
public barcodeReaderOptions = {
Symbologies: {
All: true,
@@ -122,39 +124,8 @@ export class DwtComponent implements OnInit, OnDestroy {
},
Mode: "balance",
showRects: true,
- rectShowingTime: 3
- };
- public OCREngine = "Choose...";
- public OCRLanguages = [];
- public OCROutputFormats = [];
- public OCRProFindTextFlags = [];
- public OCRProFindTextAction = [];
- public OCRProLanguages = [];
- public OCRProRecognitionModule = [];
- public OCRProOutputFormat = [];
- public OCRProPDFVersion = [];
- public OCRProPDFAVersion = [];
- public ocrOptions = {
- engine: "basic",
- Language: "eng",
- OutputFormat: "0"
- };
- public ocrProOptions = {
- engine: "pro",
- Language: "eng",
- OutputFormat: "TXTS",
- bFindText: false,
- textToFind: "TWAIN",
- FindTextFlags: 1,
- FindTextAction: 0,
- RecognitionModule: "AUTO",
- PDFVersion: "1.5",
- PDFAVersion: "pdf/a-1a"
- };
- public ocrProResultInfo = {
- base64Prefix: "data:application/pdf;base64,",
- extension: ".pdf",
- type: "application/pdf"
+ rectShowingTime: 3,
+ interval: null
};
public saveOptions = {
outPutType: "File",
@@ -174,21 +145,20 @@ export class DwtComponent implements OnInit, OnDestroy {
base64ButtonText: [],
saveFileText: [],
blobToShow: null
- }
+ };
+ public saveBarcodesDivScrollPos = 0;
+
+
constructor(protected dwtService: DwtService, private modalService: NgbModal) {
+
+ }
+
+ ngAfterViewInit() {
this.initDWT();
- this.bMobile = this.dwtService.runningEnvironment.bMobile;
- this.OCRLanguages = this.dwtService.OCRLanguages;
- this.OCROutputFormats = this.dwtService.OCROutputFormats;
- this.OCRProFindTextFlags = this.dwtService.OCRProFindTextFlags;
- this.OCRProFindTextAction = this.dwtService.OCRProFindTextAction;
- this.OCRProLanguages = this.dwtService.OCRProLanguages;
- this.OCRProRecognitionModule = this.dwtService.OCRProRecognitionModule;
- this.OCRProOutputFormat = this.dwtService.OCRProOutputFormat;
- this.OCRProPDFVersion = this.dwtService.OCRProPDFVersion;
- this.OCRProPDFAVersion = this.dwtService.OCRProPDFAVersion;
}
+
ngOnInit() {
+
this.eventsSubscription = this.events.subscribe(
(args: any) => {
if (args.type)
@@ -228,7 +198,8 @@ export class DwtComponent implements OnInit, OnDestroy {
switch (bufferStatus) {
default: break;
case "empty": this.emptyBuffer = true; break;
- case "changed": this.barcodeRectsOnCurrentImage = [];
+ case "changed":
+ this.barcodeRectsOnCurrentImage = [];
this.zones = [];
break;
}
@@ -244,23 +215,29 @@ export class DwtComponent implements OnInit, OnDestroy {
case "httpResponse":
this.handleOutPutMessage(input.responsString, input.type, false, false);
case "deviceName":
- this.deviceName = input.deviceName;
+ if (input.deviceName === "") {
+ this.deviceName = "Choose...";
+ } else {
+ this.deviceName = input.deviceName;
+ }
break;
case "cameraOptions":
+ if (this.deviceName === "" || this.deviceName === "Choose...")
+ break;
this.cameraOptions = input;
for (let i = 0; i < input.length; i++) {
if (input[i].current) {
- this.currentOptionItems = input[i].items;
this.currentOption = input[i].name;
+ this.currentOptionItems = input[i].items;
for (let j = 0; j < this.currentOptionItems.length; j++) {
if (this.currentOptionItems[j].checked) {
this.currentItem = this.currentOptionItems[j].value;
+ this.setupPlayVideo({ prop: this.currentOption, value: this.currentItem });
}
}
break;
}
}
- this.setUpPlayVideo();
this.playVideo();
break;
default: break;
@@ -310,15 +287,15 @@ export class DwtComponent implements OnInit, OnDestroy {
//invalid rects
return;
for (let i = 0; i < this.barcodeRects.imageIds.length; i++) {
- let currentIndex = this.DWObject.ImageIDToIndex(this.barcodeRects.imageIds[i]);
- if (this.DWObject.CurrentImageIndexInBuffer === currentIndex) {
+ let currentIndex = this.DWTObject.ImageIDToIndex(this.barcodeRects.imageIds[i]);
+ if (this.DWTObject.CurrentImageIndexInBuffer === currentIndex) {
let rectsOnOnePage = this.barcodeRects.rects[i];
let mainViewer = document.querySelector("#" + this.containerId + " .dvs-viewer-main");
let zoom = 0,
viewerWidth = mainViewer.offsetWidth,
viewerHeight = mainViewer.offsetHeight,
- imageWidth = this.DWObject.GetImageWidth(currentIndex),
- imageHeight = this.DWObject.GetImageHeight(currentIndex);
+ imageWidth = this.DWTObject.GetImageWidth(currentIndex),
+ imageHeight = this.DWTObject.GetImageHeight(currentIndex);
this.mainViewerPos.y = mainViewer.getBoundingClientRect().top;
this.mainViewerPos.x = mainViewer.getBoundingClientRect().left;
if (viewerWidth >= imageWidth && viewerHeight >= imageHeight) {
@@ -337,7 +314,7 @@ export class DwtComponent implements OnInit, OnDestroy {
let width = rect.w * zoom;
let height = rect.h * zoom;
//this.showMessage("x: " + rect.x + " y: " + rect.y + " w: " + rect.w + ", h: " + rect.h);
- //this.DWObject.OverlayRectangle(currentIndex, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, 0xfe8e14, 0.5);
+ //this.DWTObject.OverlayRectangle(currentIndex, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, 0xfe8e14, 0.5);
this.barcodeRectsOnCurrentImage.push({ x: left, y: top, w: width, h: height });
}
break;
@@ -345,10 +322,10 @@ export class DwtComponent implements OnInit, OnDestroy {
}
}
updateViewer() {
- if (this.DWObject){
- this.thumbnail = this.DWObject.Viewer.createThumbnailViewer({size: '20%'});
- this.DWObject.Viewer.width = "100%";
- this.DWObject.Viewer.height = "100%";
+ if (this.DWTObject){
+ this.thumbnail = this.DWTObject.Viewer.createThumbnailViewer({size: '20%'});
+ this.DWTObject.Viewer.width = "100%";
+ this.DWTObject.Viewer.height = "100%";
this.thumbnail.show();
return true;
}
@@ -356,30 +333,47 @@ export class DwtComponent implements OnInit, OnDestroy {
return false;
}
unBindViewer() {
- if (this.DWObject.Viewer.unbind()) {
- let container = document.getElementById(this.containerId);
+ if (this.DWTObject.Viewer.unbind()) {
+ let container = document.getElementById(this.containerId) as HTMLDivElement;
while (container.firstChild) {
- container.removeChild(container.lastChild);
+ container.removeChild(container.firstChild);
}
if (!this.emptyBuffer)
this.clearMessage();
return true;
} else {
- this.showMessage(this.DWObject.ErrorString);
+ this.showMessage(this.DWTObject.ErrorString);
return false;
}
}
bindViewer() {
- this.DWObject.Viewer.bind(document.getElementById(this.containerId));
- this.DWObject.Viewer.width = "100%";
- this.DWObject.Viewer.height = "100%";
- this.thumbnail = this.DWObject.Viewer.createThumbnailViewer({size: '20%'});
+ this.DWTObject.Viewer.bind(document.getElementById(this.containerId));
+ this.DWTObject.Viewer.width = "100%";
+ this.DWTObject.Viewer.height = "100%";
+ this.DWTObject.Viewer.on("wheel", ()=>{
+ this.barcodeReaderOptions.showRects = false;
+ if(this.barcodeReaderOptions.interval) {
+ clearInterval(this.barcodeReaderOptions.interval);
+ this.barcodeReaderOptions.interval = null;
+ }
+ this.barcodeReaderOptions.rectShowingTime = 3;
+ });
+ this.DWTObject.Viewer.on("scroll", ()=>{
+ this.barcodeReaderOptions.showRects = false;
+ if(this.barcodeReaderOptions.interval) {
+ clearInterval(this.barcodeReaderOptions.interval);
+ this.barcodeReaderOptions.interval = null;
+ }
+ this.barcodeReaderOptions.rectShowingTime = 3;
+ });
+
+ this.thumbnail = this.DWTObject.Viewer.createThumbnailViewer({size: '20%'});
if (this.thumbnail) {
- this.DWObject.Viewer.show();
+ this.DWTObject.Viewer.show();
this.thumbnail.show();
// Remove the context menu which is still not functioning correctly.
- this.DWObject.Viewer.off('imageRightClick');
- this.DWObject.Viewer.on('pageAreaSelected', (nImageIndex, rect) => {
+ this.DWTObject.Viewer.off('imageRightClick');
+ this.DWTObject.Viewer.on('pageAreaSelected', (nImageIndex, rect) => {
if (rect.length > 0) {
this.clearMessage();
var currentRect = rect[rect.length - 1];
@@ -395,14 +389,13 @@ export class DwtComponent implements OnInit, OnDestroy {
this.zones.splice(rect.length - 1, 1, { x: currentRect.x, y: currentRect.y, width: currentRect.x + currentRect.width, height: currentRect.y + currentRect.height, index: nImageIndex });
}
});
- this.DWObject.Viewer.on('OnImageAreaDeSelected', () => {
+ this.DWTObject.Viewer.on('OnImageAreaDeSelected', () => {
this.clearMessage(); this.zones = [];
});
- this.bMobile ? this.DWObject.Viewer.cursor = 'pointer' : this.DWObject.Viewer.cursor = 'crosshair';
- this.DWObject.Viewer.showPageNumber = true;
- //this.DWObject.Viewer.off('imageRightClick');
- this.bMobile ? this.thumbnail.updateViewMode({columns: 1, rows: 5}) :
- this.thumbnail.updateViewMode({columns: 1, rows: 3});
+ this.DWTObject.Viewer.cursor = 'crosshair';
+ this.DWTObject.Viewer.showPageNumber = true;
+ //this.DWTObject.Viewer.off('imageRightClick');
+ this.thumbnail.updateViewMode({columns: 1, rows: 3});
if (document.getElementById(this.containerId + "-fileInput"))
// Only allow one such input on the page
return;
@@ -413,7 +406,7 @@ export class DwtComponent implements OnInit, OnDestroy {
WASMInput.setAttribute("id", this.containerId + "-fileInput");
WASMInput.setAttribute("type", "file");
WASMInput.onclick = _ => {
- let filters = [], filter = "";
+ let filters : string[] = [], filter = "";
this.formatsToImport.JPG ? filters.push("image/jpeg") : false;
this.formatsToImport.PNG ? filters.push("image/png") : false;
this.formatsToImport.TIF ? filters.push("image/tiff") : false;
@@ -428,7 +421,7 @@ export class DwtComponent implements OnInit, OnDestroy {
WASMInput.setAttribute("accept", filter);
}
WASMInput.onchange = evt => {
- let _input = evt.target;
+ let _input = evt.target as HTMLInputElement;
this.dwtService.load(_input.files)
.then(_ => {
this.closeModal(true);
@@ -438,15 +431,15 @@ export class DwtComponent implements OnInit, OnDestroy {
document.getElementById(this.containerId).parentElement.appendChild(WASMInput);
}
else {
- console.log(this.DWObject.ErrorString);
+ console.log(this.DWTObject.ErrorString);
}
}
initDWT(): void {
- this.DWObject = null;
+ this.DWTObject = null;
this.dwtService.mountDWT()
.then(
obj => {
- this.DWObject = obj;
+ this.DWTObject = obj;
this.bWin = this.dwtService.runningEnvironment.bWin;
this.bUseCameraViaDirectShow = this.dwtService.bUseCameraViaDirectShow;
this.dwtMounted = true;
@@ -456,7 +449,7 @@ export class DwtComponent implements OnInit, OnDestroy {
}, err => this.showMessage(err));
setTimeout(() => {
this.bindViewer();
- this.DWObject.Viewer.pageMargin = 10;
+ this.DWTObject.Viewer.pageMargin = 10;
}, 0);
},
err => this.showMessage(err));
@@ -468,6 +461,7 @@ export class DwtComponent implements OnInit, OnDestroy {
beforeDismiss: (): boolean => {
switch (type) {
case "acquire":
+ this.dwtService.selectADevice("");
this.deviceName = "Choose...";
return true;
case "camera":
@@ -478,36 +472,45 @@ export class DwtComponent implements OnInit, OnDestroy {
}
else {
this.toggleVideo();
+ this.dwtService.selectADevice("");
+ this.deviceName = "Choose...";
return true;
}
} else {
+ this.dwtService.selectADevice("");
this.deviceName = "Choose...";
return this.VideoContainer.Viewer.unbind();
}
case "barcode":
- let __interval = setInterval(
+ if(this.barcodeReaderOptions.interval) {
+ clearInterval(this.barcodeReaderOptions.interval);
+ }
+
+ this.barcodeReaderOptions.interval = setInterval(
() => {
this.barcodeReaderOptions.rectShowingTime--;
- if (this.barcodeReaderOptions.rectShowingTime === 0) {
+
+ if (this.barcodeReaderOptions.rectShowingTime <= 0) {
this.barcodeReaderOptions.rectShowingTime = 3;
this.barcodeReaderOptions.showRects = false;
- clearInterval(__interval);
+ clearInterval(this.barcodeReaderOptions.interval);
+ this.barcodeReaderOptions.interval = null;
}
}, 1000);
this.barcodeButtonText = "Read";
this.handleOutPutMessage("", "", true, true);
- return true;
- case "ocr":
- this.ocrResultFiles = [];
- this.ocrResultURLs = [];
+
+ let barcodesDiv = document.querySelector('.barcodeReaderOptions');
+ if(barcodesDiv) {
+ this.saveBarcodesDivScrollPos = barcodesDiv.scrollTop;
+ }
+
return true;
case "save":
this.saveOptions.indices = [];
return true;
- break;
default:
return true;
- break;
}
}
});
@@ -564,22 +567,24 @@ export class DwtComponent implements OnInit, OnDestroy {
if (!this.emptyBuffer)
this.clearMessage();
this.barcodeReaderOptions.showRects = true;
- break;
- case "ocr":
- if (!this.emptyBuffer)
- this.clearMessage();
- if (this.bMobile) return;
- this.ocrResultString = "";
- this.ocrButtonText = "Recognize";
- if (this.OCREngine === "Pro"){
- this.showMessage("The Professional Engine is huge, please hold on while it downloads...");
+ this.barcodeRectsOnCurrentImage = [];
+ this.barcodeReaderOptions.rectShowingTime = 3;
+ if(this.barcodeReaderOptions.interval) {
+ clearInterval(this.barcodeReaderOptions.interval);
+ this.barcodeReaderOptions.interval = null;
}
+
+ setTimeout(() => {
+ let barcodesDiv = document.querySelector('.barcodeReaderOptions');
+ if(barcodesDiv)
+ barcodesDiv.scrollTo(0, this.saveBarcodesDivScrollPos);
+ }, 0);
break;
case "save":
if (!this.emptyBuffer)
this.clearMessage();
- let selectedIndices = this.DWObject.SelectedImagesIndices;
- let count = this.DWObject.HowManyImagesInBuffer;
+ let selectedIndices = this.DWTObject.SelectedImagesIndices;
+ let count = this.DWTObject.HowManyImagesInBuffer;
for (let i = 0; i < count; i++)
this.saveOptions.indices.push({ number: i, selected: !!selectedIndices.find(o => { return o == i; }) });
break;
@@ -594,20 +599,25 @@ export class DwtComponent implements OnInit, OnDestroy {
this.modalRef.dismiss();
}
handleDeviceChange(deviceType: string) {
+
+ console.log('this.deviceName 0' + this.deviceName);
if (this.deviceName === "" || this.deviceName === "Choose...")
return;
+
this.dwtService.selectADevice(this.deviceName)
.then(
done => done ? this.openADevice(deviceType) : this.showMessage("Device selecting failed!"),
error => typeof error === "string" ? this.showMessage(error) : this.showMessage("Device selecting failed!"));
}
openADevice(deviceType: string) {
+
this.clearMessage();
if (deviceType === "camera") {
if (this.videoPlaying)
this.toggleVideo();
this.toggleVideo();
}
+
}
acquire() {
this.scan();
@@ -637,133 +647,24 @@ export class DwtComponent implements OnInit, OnDestroy {
}, err => this.showMessage(err));
}
showEditor() {
- this.DWObject.Viewer.createImageEditor().show();
- this.DWObject.RegisterEvent('CloseImageEditorUI', () => {
+ this.DWTObject.Viewer.createImageEditor().show();
+ this.DWTObject.RegisterEvent('CloseImageEditorUI', () => {
this.editorShown = false;
});
this.editorShown = true;
}
- /**
- * OCR
- */
- filterZones() {
- let index = this.DWObject.CurrentImageIndexInBuffer;
- for (let i = 0; i < this.zones.length; i++) {
- if (this.zones[i].index !== index)
- this.zones.splice(index, 1);
- }
- }
- ocrEngineChange(engine: string) {
- if (engine === "Choose...") { engine = "Basic"; this.OCREngine = "Basic"; }
- if (engine === "Pro") {
- this.showMessage("The Professional Engine is huge, please hold on while it downloads...");
- this.useOCRPro = true;
- } else {
- this.useOCRPro = false;
- }
- this.bLoadingOCREngine = true;
- this.ocrReady = false;
- this.dwtService.loadOCRModule(engine).then(() => {
- this.clearMessage();
- this.bLoadingOCREngine = false;
- this.ocrReady = true;
- }, err =>this.showMessage(err)
- );
- }
- ocrProOutPutFormatChange(format: string) {
- switch (format) {
- case "TXTS":
- case "TXTCSV":
- if (format === "TXTCSV")
- this.ocrProResultInfo = {
- base64Prefix: "data:text/csv;base64,",
- extension: ".csv",
- type: "text/csv"
- };
- case "TXTF":
- if (format === "TXTF")
- this.ocrProResultInfo = {
- base64Prefix: "data:application/rtf;base64,",
- extension: ".rtf",
- type: "application/rtf"
- };
- case "XML":
- if (format === "XML")
- this.ocrProResultInfo = {
- base64Prefix: "data:text/xml;base64,",
- extension: ".pdf",
- type: "text/xml"
- };
- this.ocrProOptions.bFindText = false; break;
- case "IOTPDF":
- case "IOTPDF_MRC":
- this.ocrProResultInfo = {
- base64Prefix: "data:application/pdf;base64,",
- extension: ".pdf",
- type: "application/pdf"
- };
- default: break;
- }
- }
- doOCR() {
-
- this.ocrResultFiles = [];
- this.ocrResultURLs = [];
- this.ocrButtonText = "Recognizing";
- if (!this.emptyBuffer)
- this.clearMessage();
- this.ocrResultString = "";
- this.filterZones();
- let ocrOptions = this.ocrOptions;
- if (this.OCREngine === "Pro")
- ocrOptions = this.ocrProOptions;
- this.dwtService.ocr(ocrOptions, this.zones)
- .then(
- res => {
- this.ocrButtonText = "Done, click to do it again"
- this.clearMessage();
- let resultStrings = res.split(",");
- let format = this.ocrOptions.OutputFormat;
- if (this.OCREngine === "Pro")
- format = this.ocrProOptions.OutputFormat;
- switch (format) {
- case "TXTS":
- case "0" /* TEXT */:
- let stringToShow: string[] = [];
- for (let i = 0; i < resultStrings.length; i++) {
- stringToShow.push(atob(resultStrings[i]));
- }
- this.ocrResultString = stringToShow.join("\n"); break;
- case "1" /* Text PDF */:
- case "2" /* Image PDF */:
- case "IOTPDF":
- case "IOTPDF_MRC":
- case "TXTCSV":
- case "TXTF":
- case "XML":
- this.ocrResultFiles = [];
- this.ocrResultURLs = [];
- for (let i = 0; i < resultStrings.length; i++) {
- fetch(this.ocrProResultInfo.base64Prefix + resultStrings[i])
- .then(r => r.blob())
- .then(blob => {
- let newFile = new File([blob], "OCR_Result_" + i + this.ocrProResultInfo.extension, { type: this.ocrProResultInfo.type });
- this.ocrResultFiles.push(newFile);
- this.ocrResultURLs.push(URL.createObjectURL(newFile));
- });
- }
- break;
- default: break;
- }
- }, err => { this.showMessage(err); this.ocrButtonText = "Recognize failed, try again!" }
- );
- }
readBarcode() {
if (this.outputMessages.length > 0) {
this.handleOutPutMessage("", "", true, true);
this.barcodeButtonText = "Read";
return;
}
+
+ let barcodesDiv = document.querySelector('.barcodeReaderOptions');
+ if(barcodesDiv) {
+ this.saveBarcodesDivScrollPos = barcodesDiv.scrollTop;
+ }
+
this.barcodeButtonText = "Reading...";
let formatId = 0, formatId2 = 0;
this.barcodeReaderOptions.Symbologies.Aztec ? formatId += Dynamsoft.DBR.EnumBarcodeFormat.BF_AZTEC : formatId += 0;
@@ -785,20 +686,24 @@ export class DwtComponent implements OnInit, OnDestroy {
+ Dynamsoft.DBR.EnumBarcodeFormat_2.BF2_RM4SCC
+ Dynamsoft.DBR.EnumBarcodeFormat_2.BF2_PLANET
: formatId2 += 0;
- this.barcodeRectsOnCurrentImage.splice(0, this.barcodeRectsOnCurrentImage.length);
- this.filterZones();
this.dwtService.readBarcode({ formatId: formatId, formatId2: formatId2, zones: this.zones });
}
hideBarcodeTextResults() {
this.barcodeButtonText = "Read";
this.handleOutPutMessage("", "", true, true);
+
+ setTimeout(() => {
+ let barcodesDiv = document.querySelector('.barcodeReaderOptions');
+ if(barcodesDiv)
+ barcodesDiv.scrollTo(0, this.saveBarcodesDivScrollPos);
+ }, 0);
}
handleOutPutMessage(message: string, type: string, bReset: boolean, bNoScroll: boolean) {
let _noScroll = false, _type = "info";
if (type)
_type = type;
if (_type === "httpResponse") {
- let msgWindow = window.open("", "Response from server", "height=500,width=750,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no");
+ let msgWindow = window.open("", "Response from server", "height=500,width=750,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no") as Window;
msgWindow.document.writeln(message);
} else {
if (bNoScroll)
@@ -814,6 +719,10 @@ export class DwtComponent implements OnInit, OnDestroy {
}
}
handleOptionChange() {
+
+ if (this.deviceName === "" || this.deviceName === "Choose...")
+ return;
+
for (let i = 0; i < this.cameraOptions.length; i++) {
if (this.cameraOptions[i].name === this.currentOption) {
this.cameraOptions[i].current = true;
@@ -825,25 +734,29 @@ export class DwtComponent implements OnInit, OnDestroy {
for (let j = 0; j < this.currentOptionItems.length; j++) {
if (this.currentOptionItems[j].checked) {
this.currentItem = this.currentOptionItems[j].value;
- this.setUpPlayVideo({ prop: this.currentOption, value: this.currentItem });
+ this.setupPlayVideo({ prop: this.currentOption, value: this.currentItem });
this.playVideo();
break;
}
}
}
handleItemPicked() {
+
+ if (this.deviceName === "" || this.deviceName === "Choose...")
+ return;
+
for (let j = 0; j < this.currentOptionItems.length; j++) {
if (this.currentItem === this.currentOptionItems[j].value) {
this.currentOptionItems[j].checked = true;
- this.setUpPlayVideo({ prop: this.currentOption, value: this.currentItem });
+ this.setupPlayVideo({ prop: this.currentOption, value: this.currentItem });
this.playVideo();
} else {
this.currentOptionItems[j].checked = false;
}
}
}
- setUpPlayVideo(config?) {
- let _dwt = this.DWObject;
+ setupPlayVideo(config?) {
+ let _dwt = this.DWTObject;
if (this.VideoContainer)
_dwt = this.VideoContainer;
let basicSetting, moreSetting;
@@ -891,10 +804,10 @@ export class DwtComponent implements OnInit, OnDestroy {
}
}
playVideo() {
- let _dwt = this.DWObject;
+ let _dwt = this.DWTObject;
if (this.bUseCameraViaDirectShow) {
- this.DWObject.Addon.Webcam.StopVideo();
- this.DWObject.Addon.Webcam.CloseSource();
+ this.DWTObject.Addon.Webcam.StopVideo();
+ this.DWTObject.Addon.Webcam.CloseSource();
}
if (this.VideoContainer)
@@ -913,7 +826,7 @@ export class DwtComponent implements OnInit, OnDestroy {
}
}
toggleVideo() {
- let _dwt = this.DWObject;
+ let _dwt = this.DWTObject;
if (this.VideoContainer)
_dwt = this.VideoContainer;
if (this.videoPlaying) {
@@ -925,7 +838,7 @@ export class DwtComponent implements OnInit, OnDestroy {
return this.playVideo();
}
handleRangeReset() {
- let _dwt = this.DWObject;
+ let _dwt = this.DWTObject;
if (this.VideoContainer)
_dwt = this.VideoContainer;
this.rangePicker.bCamera
@@ -934,7 +847,7 @@ export class DwtComponent implements OnInit, OnDestroy {
this.rangePicker.value = this.rangePicker.default;
}
handleRangeChange() {
- let _dwt = this.DWObject;
+ let _dwt = this.DWTObject;
if (this.VideoContainer)
_dwt = this.VideoContainer;
this.rangePicker.bCamera
@@ -998,30 +911,29 @@ export class DwtComponent implements OnInit, OnDestroy {
}
handleMultiPageCheck() {
if (this.saveOptions.multiPage) {
- if (this.DWObject.SelectedImagesIndices.length === 1) {
+ if (this.DWTObject.SelectedImagesIndices.length === 1) {
this.saveOptions.indices.forEach((value, index, arr) => { value.selected = true; arr[index] = value; });
- this.DWObject.SelectAllImages();
+ this.DWTObject.SelectAllImages();
}
} else {
- if (this.DWObject.SelectedImagesIndices.length > 1)
- this.DWObject.SelectImages([this.DWObject.CurrentImageIndexInBuffer]);
+ if (this.DWTObject.SelectedImagesIndices.length > 1)
+ this.DWTObject.SelectImages([this.DWTObject.CurrentImageIndexInBuffer]);
this.saveOptions.indices.forEach((value, index, arr) => {
value.selected = false;
- if (value.number === this.DWObject.CurrentImageIndexInBuffer)
+ if (value.number === this.DWTObject.CurrentImageIndexInBuffer)
value.selected = true;
arr[index] = value;
});
}
}
handleIndexSelection(selected: boolean, index: number) {
- let selectedIndices = this.DWObject.SelectedImagesIndices;
+ let selectedIndices = this.DWTObject.SelectedImagesIndices;
if (selected) {
selectedIndices.push(index);
} else {
selectedIndices.splice(selectedIndices.indexOf(index), 1);
}
- selectedIndices.sort();
- this.DWObject.SelectImages(selectedIndices);
+ this.DWTObject.SelectImages(selectedIndices);
}
handleOutPutFormatChange(format) {
if (format !== "PDF" && format !== "TIF") {
@@ -1041,12 +953,12 @@ export class DwtComponent implements OnInit, OnDestroy {
case "File":
if (this.saveOptions.upload) {
if (this.saveOptions.multiPage) {
- let selectedIndices = this.DWObject.SelectedImagesIndices;
+ let selectedIndices = this.DWTObject.SelectedImagesIndices;
this.dwtService.uploadToServer(selectedIndices, this.getImageType(this.saveOptions.outPutFormat), this.saveOptions.fileName)
.then(result => { this.saveResults.uploadedFiles.push(result); this.clearMessage(); }, err => this.showMessage(err));
}
else {
- let count = this.DWObject.HowManyImagesInBuffer;
+ let count = this.DWTObject.HowManyImagesInBuffer;
for (let i = 0; i < count; i++) {
this.dwtService.uploadToServer([i], this.getImageType(this.saveOptions.outPutFormat), this.saveOptions.fileName + "_" + (i + 1))
.then(result => { this.saveResults.uploadedFiles.push(result); this.clearMessage(); }, err => this.showMessage(err));
@@ -1054,7 +966,7 @@ export class DwtComponent implements OnInit, OnDestroy {
}
} else {
if (this.saveOptions.multiPage) {
- let selectedIndices = this.DWObject.SelectedImagesIndices;
+ let selectedIndices = this.DWTObject.SelectedImagesIndices;
let type = this.getImageType(this.saveOptions.outPutFormat);
if (type === 2) type = 8;
if (type === 4) type = 7;
@@ -1066,7 +978,7 @@ export class DwtComponent implements OnInit, OnDestroy {
}, err => this.showMessage(err));
}
else {
- let count = this.DWObject.HowManyImagesInBuffer;
+ let count = this.DWTObject.HowManyImagesInBuffer;
let fileName = this.saveOptions.fileName + "_" + 1;
this.dwtService.saveLocally([0], this.getImageType(this.saveOptions.outPutFormat), fileName, true)
.then(result => {
@@ -1091,7 +1003,7 @@ export class DwtComponent implements OnInit, OnDestroy {
break;
case "Blob":
if (this.saveOptions.multiPage) {
- let selectedIndices = this.DWObject.SelectedImagesIndices;
+ let selectedIndices = this.DWTObject.SelectedImagesIndices;
this.dwtService.getBlob(
selectedIndices,
this.getImageType(this.saveOptions.outPutFormat))
@@ -1102,7 +1014,7 @@ export class DwtComponent implements OnInit, OnDestroy {
this.clearMessage();
}, err => this.showMessage(err));
} else {
- let count = this.DWObject.HowManyImagesInBuffer;
+ let count = this.DWTObject.HowManyImagesInBuffer;
for (let i = 0; i < count; i++) {
this.dwtService.getBlob(
[i],
@@ -1118,7 +1030,7 @@ export class DwtComponent implements OnInit, OnDestroy {
break;
case "Base64":
if (this.saveOptions.multiPage) {
- let selectedIndices = this.DWObject.SelectedImagesIndices;
+ let selectedIndices = this.DWTObject.SelectedImagesIndices;
this.dwtService.getBase64(
selectedIndices,
this.getImageType(this.saveOptions.outPutFormat))
@@ -1128,7 +1040,7 @@ export class DwtComponent implements OnInit, OnDestroy {
this.clearMessage();
}, err => this.showMessage(err));
} else {
- let count = this.DWObject.HowManyImagesInBuffer;
+ let count = this.DWTObject.HowManyImagesInBuffer;
for (let i = 0; i < count; i++) {
this.dwtService.getBase64(
[i],
diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts
index a4d01b4..9e356f0 100644
--- a/src/environments/environment.prod.ts
+++ b/src/environments/environment.prod.ts
@@ -2,7 +2,7 @@ export const environment = {
production: true,
Dynamsoft: {
resourcesPath: 'assets/dwt-resources',
- dwtProductKey: 't0100CgEAAI/Kalkph+rANa7xvFeYzy2ZJaF0sV188r8K/knF/akFHHvAHdHAtGHQJrpxP+nqlDJkXOD65sKMbWhdmp6b7QgCWLr5A0huNQqu+DW0v3gAgcFwAvEGSBQj0nwHo981mg==',
+ dwtProductKey: 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9',
uploadTargetURL: ''
}
};
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index 497e480..5ea7cbd 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -6,7 +6,7 @@ export const environment = {
production: false,
Dynamsoft: {
resourcesPath: 'assets/dwt-resources',
- dwtProductKey: 't0100CgEAAI/Kalkph+rANa7xvFeYzy2ZJaF0sV188r8K/knF/akFHHvAHdHAtGHQJrpxP+nqlDJkXOD65sKMbWhdmp6b7QgCWLr5A0huNQqu+DW0v3gAgcFwAvEGSBQj0nwHo981mg==',
+ dwtProductKey: 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9',
uploadTargetURL: ''
}
};
diff --git a/src/main.ts b/src/main.ts
index c7b673c..e73044b 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,12 +1,24 @@
-import { enableProdMode } from '@angular/core';
-import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
+import { enableProdMode, importProvidersFrom } from '@angular/core';
+import { bootstrapApplication } from '@angular/platform-browser';
-import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
+import { DwtService } from './app/dwt.service';
+import { AppComponent } from './app/app.component';
+import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
+import { BrowserModule } from '@angular/platform-browser';
+import { FormsModule } from '@angular/forms';
if (environment.production) {
enableProdMode();
}
-platformBrowserDynamic().bootstrapModule(AppModule)
- .catch(err => console.error(err));
+bootstrapApplication(AppComponent, {
+ providers: [
+ importProvidersFrom([
+ DwtService,
+ NgbModule,
+ BrowserModule,
+ FormsModule
+ ])
+ ]
+}).catch(err => console.error(err));
diff --git a/src/styles.css b/src/styles.css
index 616f107..e70b577 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -13,3 +13,9 @@ a#dwt-btn-install:hover {
margin-top: 0;
margin-bottom: 0;
}
+
+.close {
+ position: absolute;
+ top: 15px;
+ right: 15px;
+}
\ No newline at end of file
diff --git a/tsconfig.base.json b/tsconfig.base.json
index f69f654..454d8a9 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -10,7 +10,7 @@
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
- "target": "es2015",
+ "target": "es2022",
"module": "es2020",
"lib": [
"es2018",
diff --git a/tsconfig.json b/tsconfig.json
index 2338536..350a982 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,17 +1,14 @@
-/*
- This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience.
- It is not intended to be used to perform a compilation.
-
- To learn more about this file see: https://angular.io/config/solution-tsconfig.
-*/
{
- "files": [],
- "references": [
- {
- "path": "./tsconfig.app.json"
- },
- {
- "path": "./tsconfig.spec.json"
- }
-]
+ "extends": "./tsconfig.base.json",
+ "compilerOptions": {
+ "outDir": "./out-tsc/app",
+ "types": []
+ },
+ "files": [
+ "src/main.ts"
+ ],
+ "include": [
+ "src/**/*.d.ts"
+ ]
}
+