@regulaforensics/document-reader 8.2.204-beta → 8.3.246-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +2 -3
  2. package/RNDocumentReader.podspec +2 -2
  3. package/android/build.gradle +2 -2
  4. package/android/cordova.gradle +2 -2
  5. package/android/src/main/java/com/regula/plugin/documentreader/Config.kt +3 -1
  6. package/examples/capacitor/README.md +10 -0
  7. package/examples/capacitor/index.html +2 -7
  8. package/examples/capacitor/index.tsx +39 -0
  9. package/examples/capacitor/package.json +3 -3
  10. package/examples/capacitor/scripts/setup.sh +4 -0
  11. package/examples/capacitor/src/extra/bt_device.tsx +8 -7
  12. package/examples/capacitor/src/extra/custom_rfid.tsx +8 -8
  13. package/examples/capacitor/src/main.css +4 -1
  14. package/examples/capacitor/src/main.html +1 -4
  15. package/examples/capacitor/src/main.tsx +58 -94
  16. package/examples/ionic/README.md +10 -0
  17. package/examples/ionic/config.xml +2 -0
  18. package/examples/ionic/index.tsx +54 -0
  19. package/examples/ionic/package.json +3 -3
  20. package/examples/ionic/src/extra/{bt_device.ts → bt_device.tsx} +8 -7
  21. package/examples/ionic/src/extra/{custom_rfid.ts → custom_rfid.tsx} +8 -8
  22. package/examples/ionic/src/main.css +4 -1
  23. package/examples/ionic/src/main.html +1 -4
  24. package/examples/ionic/src/main.tsx +171 -0
  25. package/examples/ionic/tsconfig.json +3 -2
  26. package/examples/react_native/README.md +10 -0
  27. package/examples/react_native/index.tsx +28 -5
  28. package/examples/react_native/package-lock.json +476 -421
  29. package/examples/react_native/package.json +10 -10
  30. package/examples/react_native/src/extra/bt_device.tsx +8 -8
  31. package/examples/react_native/src/extra/custom_rfid.tsx +8 -9
  32. package/examples/react_native/src/main.css +4 -1
  33. package/examples/react_native/src/main.html +1 -4
  34. package/examples/react_native/src/main.tsx +59 -84
  35. package/ios/RGLWConfig.m +2 -0
  36. package/package.json +1 -1
  37. package/plugin.xml +2 -2
  38. package/www/capacitor/index.js +16 -16
  39. package/www/capacitor/params/process_params/ProcessParams.js +7 -0
  40. package/www/cordova.js +23 -16
  41. package/www/react-native/index.js +16 -16
  42. package/www/react-native/params/process_params/ProcessParams.js +7 -0
  43. package/www/types/index.d.ts +8 -8
  44. package/www/types/params/process_params/ProcessParams.d.ts +4 -0
  45. package/examples/cordova/.vscode/launch.json +0 -28
  46. package/examples/cordova/.vscode/typings/cordova/cordova.d.ts +0 -80
  47. package/examples/cordova/README.md +0 -12
  48. package/examples/cordova/config.xml +0 -30
  49. package/examples/cordova/package-lock.json +0 -1314
  50. package/examples/cordova/package.json +0 -32
  51. package/examples/cordova/scripts/android.sh +0 -8
  52. package/examples/cordova/scripts/ios.sh +0 -8
  53. package/examples/cordova/scripts/setup.sh +0 -8
  54. package/examples/cordova/www/images/document.png +0 -0
  55. package/examples/cordova/www/images/logo.png +0 -0
  56. package/examples/cordova/www/images/portrait.png +0 -0
  57. package/examples/cordova/www/index.html +0 -6
  58. package/examples/cordova/www/index.js +0 -40
  59. package/examples/cordova/www/src/extra/bt_device.js +0 -31
  60. package/examples/cordova/www/src/extra/custom_rfid.js +0 -60
  61. package/examples/cordova/www/src/main.css +0 -131
  62. package/examples/cordova/www/src/main.html +0 -41
  63. package/examples/cordova/www/src/main.js +0 -202
  64. package/examples/ionic/index.ts +0 -16
  65. package/examples/ionic/src/main.ts +0 -213
package/README.md CHANGED
@@ -1,10 +1,9 @@
1
1
  # Regula Document Reader plugin
2
- Document Reader allows you to read various kinds of identification documents, passports, driving licenses, ID cards, etc. All processing is performed completely offline on your device. This plugin makes possible to use it with react-native, cordova and ionic applications.
2
+ Document Reader allows you to read various kinds of identification documents, passports, driving licenses, ID cards, etc. All processing is performed completely offline on your device. This plugin makes possible to use it with react-native, cordova and capacitor applications.
3
3
 
4
4
  ## Demo applications
5
- In the [examples](examples/) folder you can find 4 demo applications:
5
+ In the [examples](examples/) folder you can find 3 demo applications:
6
6
  * [React-native](examples/react-native)
7
- * [Cordova](examples/cordova)
8
7
  * [Ionic(ionic app with cordova, angular)](examples/ionic)
9
8
  * [Capacitor(ionic app with capacitor, react)](examples/capacitor)
10
9
 
@@ -5,7 +5,7 @@ source = File.join(__dir__, 'ios')
5
5
 
6
6
  Pod::Spec.new do |s|
7
7
  s.name = 'RNDocumentReader'
8
- s.version = '8.2.204-beta'
8
+ s.version = '8.3.246-beta'
9
9
  s.summary = package['description']
10
10
  s.license = package['license']
11
11
 
@@ -16,6 +16,6 @@ Pod::Spec.new do |s|
16
16
  s.ios.deployment_target = '13.0'
17
17
  s.source_files = 'ios/**/*.{h,m}'
18
18
  s.exclude_files = [ 'ios/CVDDocumentReader.h', 'ios/CVDDocumentReader.m' ]
19
- s.dependency 'DocumentReaderStage', '8.2.4879'
19
+ s.dependency 'DocumentReader', '8.2.4934'
20
20
  s.dependency 'React'
21
21
  end
@@ -20,7 +20,7 @@ android {
20
20
  rootProject.allprojects {
21
21
  repositories {
22
22
  maven {
23
- url "https://maven.regulaforensics.com/RegulaDocumentReader/Stage"
23
+ url "https://maven.regulaforensics.com/RegulaDocumentReader"
24
24
  }
25
25
  }
26
26
  }
@@ -29,7 +29,7 @@ dependencies {
29
29
  //noinspection GradleDynamicVersion
30
30
  implementation 'com.facebook.react:react-native:+'
31
31
  //noinspection GradleDependency
32
- implementation('com.regula.documentreader:api:8.2.11640'){
32
+ implementation('com.regula.documentreader:api:8.2.11679'){
33
33
  transitive = true
34
34
  }
35
35
  }
@@ -1,12 +1,12 @@
1
1
  repositories {
2
2
  maven {
3
- url "https://maven.regulaforensics.com/RegulaDocumentReader/Stage"
3
+ url "https://maven.regulaforensics.com/RegulaDocumentReader"
4
4
  }
5
5
  }
6
6
 
7
7
  dependencies {
8
8
  //noinspection GradleDependency
9
- implementation('com.regula.documentreader:api:8.2.11640'){
9
+ implementation('com.regula.documentreader:api:8.2.11679'){
10
10
  transitive = true
11
11
  }
12
12
  }
@@ -137,6 +137,7 @@ fun setProcessParams(processParams: ProcessParam, opts: JSONObject) = opts.forEa
137
137
  "generateDTCVC" -> processParams.generateDTCVC = v as Boolean
138
138
  "strictDLCategoryExpiry" -> processParams.strictDLCategoryExpiry = v as Boolean
139
139
  "generateAlpha2Codes" -> processParams.generateAlpha2Codes = v as Boolean
140
+ "disableAuthResolutionFilter" -> processParams.disableAuthResolutionFilter = v as Boolean
140
141
  "measureSystem" -> processParams.measureSystem = v.toInt()
141
142
  "barcodeParserType" -> processParams.barcodeParserType = v.toInt()
142
143
  "perspectiveAngle" -> processParams.perspectiveAngle = v.toInt()
@@ -221,6 +222,7 @@ fun getProcessParams(processParams: ProcessParam) = mapOf(
221
222
  "generateDTCVC" to processParams.generateDTCVC,
222
223
  "strictDLCategoryExpiry" to processParams.strictDLCategoryExpiry,
223
224
  "generateAlpha2Codes" to processParams.generateAlpha2Codes,
225
+ "disableAuthResolutionFilter" to processParams.disableAuthResolutionFilter,
224
226
  "measureSystem" to processParams.measureSystem,
225
227
  "barcodeParserType" to processParams.barcodeParserType,
226
228
  "perspectiveAngle" to processParams.perspectiveAngle,
@@ -316,7 +318,7 @@ fun setCustomization(customization: ParamsCustomization, opts: JSONObject) = opt
316
318
  "torchButtonOnImage" -> editor.setTorchImageOn(v.toDrawable())
317
319
  "torchButtonOffImage" -> editor.setTorchImageOff(v.toDrawable())
318
320
  "livenessAnimationImage" -> editor.setLivenessAnimationImage(v.toDrawable())
319
- "multipageButtonImage" -> editor.setMultipageButtonDrawable(v.toDrawable())
321
+ "multipageButtonImage" -> editor.setMultipageButtonImage(v.toDrawable())
320
322
  "helpAnimationImageMatrix" -> editor.setHelpAnimationImageMatrix(matrixFromJSON(v as JSONArray?)).setHelpAnimationImageScaleType(ImageView.ScaleType.MATRIX)
321
323
  "multipageAnimationFrontImageMatrix" -> editor.setMultipageAnimationFrontImageMatrix(matrixFromJSON(v as JSONArray?)).setMultipageAnimationFrontImageScaleType(ImageView.ScaleType.MATRIX)
322
324
  "multipageAnimationBackImageMatrix" -> editor.setMultipageAnimationBackImageMatrix(matrixFromJSON(v as JSONArray?)).setMultipageAnimationBackImageScaleType(ImageView.ScaleType.MATRIX)
@@ -10,3 +10,13 @@
10
10
  * Android: `npm run android`.
11
11
 
12
12
  **Note**: this is just one way of running the app. You can also pass `-o` or `--open` argument to the command, and this will open Xcode/Android Studio, then run the app directly from the IDE. Overall, this is a more consistent way, so if you're having troubles running the app from terminal, try running it from the IDE.
13
+
14
+ ## Additional examples
15
+
16
+ ### Bluetooth device
17
+
18
+ In order to connect to an external scanning device, change the `useBtDevice` constant to true in `src/extra/bt_device`, and set `btDeviceName` to the name of you device. After running the app, click `Connect`.
19
+
20
+ ### RFID self hosted UI
21
+
22
+ This app also demonstraits how you can implement you own UI for the RFID reading process. To enable it, change the `useRfidSelfHostedUI` constant to true in `src/extra/custom_rfid`. Run the app and initiate RFID reading.
@@ -1,10 +1,5 @@
1
1
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
2
- <script type="module" src="/src/main.tsx"></script>
3
-
4
2
  <div id="content" style="height: 100%"></div>
5
3
 
6
- <script>
7
- fetch("main.html")
8
- .then(response => response.text())
9
- .then(html => document.getElementById("content").innerHTML = html)
10
- </script>
4
+ <script type="module" src="./index.tsx"></script>
5
+ <script type="module" src="/src/main.tsx"></script>
@@ -0,0 +1,39 @@
1
+ import '@ionic/react/css/core.css'
2
+ import '/src/main.css'
3
+ import { setupIonicReact } from '@ionic/react'
4
+ import { StatusBar, Style } from '@capacitor/status-bar'
5
+ import { File } from '@awesome-cordova-plugins/file'
6
+ import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera'
7
+ import { main } from './src/main'
8
+
9
+ document.addEventListener('deviceready', () => fetch("main.html")
10
+ .then(response => response.text())
11
+ .then(html => document.getElementById("content").innerHTML = html)
12
+ .then(_ => document.dispatchEvent(new Event('ready')))
13
+ )
14
+
15
+ export async function loadAsset(path: string): Promise<string> {
16
+ var dir = await File.resolveDirectoryUrl(File.applicationDirectory + "public/assets")
17
+ var fileEntry = await File.getFile(dir, path, {})
18
+ var result = await new Promise<string>((resolve, _) => {
19
+ fileEntry.file(file => {
20
+ var reader = new FileReader()
21
+ reader.onloadend = (_) => resolve(reader.result as string)
22
+ reader.readAsDataURL(file)
23
+ })
24
+ })
25
+ return result
26
+ }
27
+
28
+ export async function pickImage(): Promise<string | null> {
29
+ return await Camera.getPicture({
30
+ destinationType: DestinationType.DATA_URL,
31
+ mediaType: MediaType.PICTURE,
32
+ sourceType: PictureSourceType.PHOTOLIBRARY
33
+ })
34
+ }
35
+
36
+ document.addEventListener('ready', main)
37
+
38
+ setupIonicReact()
39
+ StatusBar.setStyle({ style: Style.Light })
@@ -6,9 +6,9 @@
6
6
  "android": "scripts/android.sh"
7
7
  },
8
8
  "dependencies": {
9
- "@regulaforensics/document-reader": "8.2.204-beta",
10
- "@regulaforensics/document-reader-core-fullauthrfid": "8.2.8-beta",
11
- "@regulaforensics/document-reader-btdevice": "8.2.8-beta",
9
+ "@regulaforensics/document-reader": "8.3.246-beta",
10
+ "@regulaforensics/document-reader-core-fullauthrfid": "8.3.9-beta",
11
+ "@regulaforensics/document-reader-btdevice": "8.3.10-beta",
12
12
  "@awesome-cordova-plugins/file": "6.6.0",
13
13
  "@awesome-cordova-plugins/camera": "6.6.0",
14
14
  "@awesome-cordova-plugins/dialogs": "6.6.0",
@@ -4,3 +4,7 @@ set -e
4
4
  npm install
5
5
  cd ios/App
6
6
  pod install || pod update
7
+ cd ../../
8
+
9
+ cp public/assets/db.dat ios/App/App/
10
+ cp public/assets/db.dat android/app/src/main/assets/Regula/
@@ -1,26 +1,27 @@
1
1
  import { DocumentReader, InitConfig } from "@regulaforensics/document-reader"
2
- import { handleException, setStatus } from "../main"
2
+ import { handleException, init, setStatus } from "../main"
3
3
 
4
4
  export const useBtDevice = false
5
- const btDeviceName = "Regula 0000"
5
+ export const btDeviceName = "Regula 0000"
6
6
 
7
7
  export function setupBTDevice() {
8
- document.getElementById("bt-device").style.display = "flex"
9
- document.getElementById("connect").onclick = () => connect()
8
+ var connectButton = document.getElementById("connect")!
9
+ connectButton.style.display = "flex"
10
+ connectButton.onclick = () => connect()
10
11
  setStatus("Connect to a bluetooth device")
11
12
  }
12
13
 
13
14
  async function connect() {
14
15
  setStatus("Searching for devices...")
15
16
  if (await DocumentReader.instance.connectBluetoothDevice(btDeviceName)) {
16
- await initialize()
17
+ await init()
17
18
  DocumentReader.instance.functionality.useAuthenticator = true
18
- document.getElementById("bt-device").style.display = "none"
19
+ document.getElementById("bt-device")!.style.display = "none"
19
20
  } else
20
21
  setStatus("Failed to connect")
21
22
  }
22
23
 
23
- async function initialize() {
24
+ export async function initializeWithBTDevice() {
24
25
  setStatus("Initializing...")
25
26
 
26
27
  var initConfig = InitConfig.withBleDevice()
@@ -28,7 +28,7 @@ function setup() {
28
28
  setProgress(-1)
29
29
  currentProgress = -1
30
30
  setShowing(true)
31
- document.getElementById("cancel-rfid").onclick = () => stop()
31
+ document.getElementById("cancel-rfid")!.onclick = () => stop()
32
32
  }
33
33
 
34
34
  function stop() {
@@ -37,13 +37,13 @@ function stop() {
37
37
  setShowing(false)
38
38
  }
39
39
 
40
- function setDescription(data) {
41
- document.getElementById("rfid-description").innerHTML = data
40
+ function setDescription(data: string) {
41
+ document.getElementById("rfid-description")!.innerHTML = data
42
42
  }
43
43
 
44
44
  var currentProgress = -1
45
- function setProgress(next) {
46
- var progress = document.getElementById("progress")
45
+ function setProgress(next: number) {
46
+ var progress = document.getElementById("progress")!
47
47
  // make progress bar look better
48
48
  if (next == 0) return // ignore idle 0s, leave progress at 100 while its not moving
49
49
  if (next < currentProgress) next = 0 // move to 0 if progress finaly started moving
@@ -55,7 +55,7 @@ function setProgress(next) {
55
55
  currentProgress = next
56
56
  }
57
57
 
58
- function setShowing(data) {
59
- document.getElementById("main").style.display = data ? "none" : "flex"
60
- document.getElementById("custom-rfid").style.display = data ? "flex" : "none"
58
+ function setShowing(data: boolean) {
59
+ document.getElementById("main")!.style.display = data ? "none" : "flex"
60
+ document.getElementById("custom-rfid")!.style.display = data ? "flex" : "none"
61
61
  }
@@ -1,8 +1,10 @@
1
1
  html,
2
2
  body {
3
- width: 99%;
3
+ margin: 0;
4
+ width: 100%;
4
5
  height: 99vh;
5
6
  display: flex;
7
+ overflow: hidden;
6
8
  flex-direction: column;
7
9
  }
8
10
 
@@ -59,6 +61,7 @@ body {
59
61
  color: white;
60
62
  border: none;
61
63
  padding: 10px 20px;
64
+ justify-content: center;
62
65
  font-size: 16px;
63
66
  border-radius: 100px;
64
67
  cursor: pointer;
@@ -14,10 +14,6 @@
14
14
  <img id="document-image" src="images/document.png" height="160px" width="200px">
15
15
  </div>
16
16
  </div>
17
- <div id="bt-device" class="row" style="display: none;">
18
- <input type="text" placeholder="Regula 0000" />
19
- <button id="connect" class="button">Connect</button>
20
- </div>
21
17
  <div id="scenario-container" class="column no-scroll" style="margin-top: 15px; background-color: rgba(0, 0, 0, 0.03);">
22
18
  <div id="scenarios" class="scroll"></div>
23
19
  </div>
@@ -29,6 +25,7 @@
29
25
  <button id="scan" class="button">Scan document</button>
30
26
  <button id="recognize" class="button">Scan image</button>
31
27
  </div>
28
+ <button id="connect" class="button" style="width: 360px; display: none;">Connect</button>
32
29
  <div style="padding-top: 20px;"></div>
33
30
  </div>
34
31
  <div id="custom-rfid" class="column no-scroll" style="display: none;">
@@ -1,20 +1,14 @@
1
- import '@ionic/react/css/core.css'
2
- import './main.css'
3
- import { setupIonicReact } from '@ionic/react'
4
- import { StatusBar, Style } from '@capacitor/status-bar'
5
- import { File } from '@awesome-cordova-plugins/file'
6
- import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera'
7
-
8
- import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario } from '@regulaforensics/document-reader'
9
- import { setupBTDevice, useBtDevice } from './extra/bt_device'
1
+ import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario, Results, DocReaderException, DocReaderScenario } from '@regulaforensics/document-reader'
2
+ import { loadAsset, pickImage } from '../index'
3
+ import { initializeWithBTDevice, setupBTDevice, useBtDevice } from './extra/bt_device'
10
4
  import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid'
11
5
 
12
6
  var documentReader = DocumentReader.instance
13
- var selectedScenario
7
+ var selectedScenario = Scenario.MRZ
14
8
  var doRfid = false
15
9
  var isReadingRfid = false
16
10
 
17
- async function init() {
11
+ export async function init() {
18
12
  if (!await initialize()) return
19
13
  setScenarios(documentReader.availableScenarios)
20
14
  setCanRfid(await documentReader.isRFIDAvailableForUse())
@@ -42,7 +36,7 @@ async function recognize() {
42
36
  )
43
37
  }
44
38
 
45
- export function handleCompletion(action, results, error) {
39
+ export function handleCompletion(action: DocReaderAction, results: Results | null, error: DocReaderException | null) {
46
40
  handleException(error)
47
41
  if (DocReaderAction.stopped(action) && !shouldRfid(results)) {
48
42
  displayResults(results)
@@ -52,7 +46,7 @@ export function handleCompletion(action, results, error) {
52
46
  }
53
47
  }
54
48
 
55
- export async function displayResults(results) {
49
+ export async function displayResults(results: Results | null) {
56
50
  isReadingRfid = false
57
51
  clearResults()
58
52
  if (results == null) return
@@ -71,13 +65,13 @@ var readRfid = () => {
71
65
  documentReader.rfid(new RFIDConfig(handleCompletion))
72
66
  }
73
67
 
74
- function shouldRfid(results) {
68
+ function shouldRfid(results: Results | null) {
75
69
  return doRfid &&
76
70
  !isReadingRfid &&
77
71
  results != null && results.chipPage != 0
78
72
  }
79
73
 
80
- async function initialize() {
74
+ var initialize = async () => {
81
75
  setStatus("Initializing...")
82
76
 
83
77
  var license = await loadAsset("regula.license")
@@ -88,26 +82,45 @@ async function initialize() {
88
82
  return success
89
83
  }
90
84
 
91
- export function handleException(error) {
85
+ export function handleException(error: DocReaderException | null) {
92
86
  if (error != null) {
93
87
  setStatus(error.message)
94
88
  console.log(error.code + ": " + error.message)
95
89
  }
96
90
  }
97
91
 
98
- // ui --------------------------------------------------------------------------------------------------------------------
92
+ // --------------------------------------------------------------------------------------------------------------------
99
93
 
100
- export function setStatus(data) {
94
+ var documentUIImage: HTMLImageElement
95
+ var portraitUIImage: HTMLImageElement
96
+ export function main() {
97
+ documentUIImage = document.getElementById("document-image") as HTMLImageElement
98
+ portraitUIImage = document.getElementById("portrait-image") as HTMLImageElement
99
+ document.getElementById("scan")!.onclick = () => scan()
100
+ document.getElementById("recognize")!.onclick = () => recognize()
101
+
102
+ // custom rfid
103
+ if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
104
+
105
+ // bt device
106
+ if (!useBtDevice) init()
107
+ else {
108
+ setupBTDevice()
109
+ initialize = initializeWithBTDevice
110
+ }
111
+ }
112
+
113
+ export function setStatus(data: string | null) {
101
114
  if (data != null)
102
- document.getElementById("status").innerHTML = data
115
+ document.getElementById("status")!.innerHTML = data
103
116
  }
104
117
 
105
- function setPortrait(data) {
118
+ function setPortrait(data: string | null) {
106
119
  if (data != null)
107
120
  portraitUIImage.src = "data:image/png;base64," + data
108
121
  }
109
122
 
110
- function setDocImage(data) {
123
+ function setDocImage(data: string | null) {
111
124
  if (data != null)
112
125
  documentUIImage.src = "data:image/png;base64," + data
113
126
  }
@@ -118,90 +131,41 @@ function clearResults() {
118
131
  documentUIImage.src = "images/document.png"
119
132
  }
120
133
 
121
- function setCanRfid(data) {
122
- var checkbox // implicitly any, since cordova sample is pure js
123
- checkbox = document.getElementById('rfid-checkbox')
124
- var checkboxDescription = document.getElementById("rfid-checkbox-description")
134
+ function setCanRfid(data: boolean) {
135
+ var checkbox = document.getElementById('rfid-checkbox') as HTMLInputElement
136
+ var checkboxDescription = document.getElementById("rfid-checkbox-description")!
125
137
  if (data) {
126
138
  checkbox.disabled = false
127
139
  checkboxDescription.innerHTML = "Process rfid reading"
128
- checkboxDescription.onclick = () => {
140
+ var onclick = () => {
129
141
  doRfid = !doRfid
130
142
  checkbox.checked = doRfid
131
143
  }
144
+ checkbox.onclick = onclick
145
+ checkboxDescription.onclick = onclick
132
146
  }
133
147
  }
134
148
 
135
- // not equal --------------------------------------------------------------------------------------------------------------------
149
+ function setScenarios(data: DocReaderScenario[]) {
150
+ var scenariosContainer = document.getElementById("scenarios")!
136
151
 
137
- async function loadAsset(path: string): Promise<string> {
138
- var dir = await File.resolveDirectoryUrl(File.applicationDirectory + "public/assets")
139
- var fileEntry = await File.getFile(dir, path, {})
140
- var result = await new Promise<string>((resolve, _) => {
141
- fileEntry.file(file => {
142
- var reader = new FileReader()
143
- reader.onloadend = (_) => resolve(reader.result as string)
144
- reader.readAsDataURL(file)
145
- })
152
+ data.forEach(scenario => {
153
+ var checked = selectedScenario == scenario.name ? "checked" : ""
154
+ var scenarioElement = `<div class="row radio">
155
+ <input type="radio" name="scenario" id="${scenario.name}" value="${scenario.name}" ${checked}>
156
+ <span id="${scenario.name}-caption" style="width: 200px; padding-left: 5px;">${scenario.caption}</span>
157
+ </div>`
158
+ scenariosContainer.insertAdjacentHTML("beforeend", scenarioElement)
146
159
  })
147
- return result
148
- }
149
160
 
150
- async function pickImage(): Promise<string | null> {
151
- return await Camera.getPicture({
152
- destinationType: DestinationType.DATA_URL,
153
- mediaType: MediaType.PICTURE,
154
- sourceType: PictureSourceType.PHOTOLIBRARY
161
+ data.forEach(scenario => {
162
+ var element = document.getElementById(scenario.name) as HTMLInputElement
163
+ var elementCaption = document.getElementById(scenario.name + "-caption")!
164
+ var onclick = () => {
165
+ selectedScenario = scenario.name as Scenario
166
+ element.checked = true
167
+ }
168
+ element.onclick = onclick
169
+ elementCaption.onclick = onclick
155
170
  })
156
171
  }
157
-
158
- var documentUIImage
159
- var portraitUIImage
160
- document.addEventListener('deviceready', () => {
161
- documentUIImage = document.getElementById("document-image")
162
- portraitUIImage = document.getElementById("portrait-image")
163
- document.getElementById("scan").onclick = () => scan()
164
- document.getElementById("recognize").onclick = () => recognize()
165
-
166
- // custom rfid
167
- if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
168
-
169
- // bt device
170
- if (!useBtDevice) init()
171
- else setupBTDevice()
172
- })
173
-
174
- // not resolved --------------------------------------------------------------------------------------------------------------------
175
-
176
- function setScenarios(data) {
177
- selectedScenario = Scenario.MRZ
178
- const scenariosContainer = document.getElementById("scenarios")
179
- data.forEach(scenario => scenariosContainer.appendChild(createScenarioElement(scenario)))
180
- }
181
-
182
- function createScenarioElement(scenario) {
183
- const div = document.createElement('div')
184
- div.className = 'row radio'
185
-
186
- const input = document.createElement('input')
187
- input.type = 'radio'
188
- input.name = 'scenario'
189
- input.value = scenario.name
190
- input.checked = scenario.name === selectedScenario
191
-
192
- const span = document.createElement('span')
193
- span.style.width = '200px'
194
- span.style.paddingLeft = '5px'
195
- span.textContent = scenario.caption
196
-
197
- input.onclick = () => selectedScenario = scenario.name
198
- span.onclick = () => input.click()
199
-
200
- div.appendChild(input)
201
- div.appendChild(span)
202
-
203
- return div
204
- }
205
-
206
- setupIonicReact()
207
- StatusBar.setStyle({ style: Style.Light })
@@ -10,3 +10,13 @@
10
10
  * Android: `npm run android`.
11
11
 
12
12
  **Note**: this is just one way of running the app. You can also pass `-o` or `--open` argument to the command, and this will open Xcode/Android Studio, then run the app directly from the IDE. Overall, this is a more consistent way, so if you're having troubles running the app from terminal, try running it from the IDE.
13
+
14
+ ## Additional examples
15
+
16
+ ### Bluetooth device
17
+
18
+ In order to connect to an external scanning device, change the `useBtDevice` constant to true in `src/extra/bt_device`, and set `btDeviceName` to the name of you device. After running the app, click `Connect`.
19
+
20
+ ### RFID self hosted UI
21
+
22
+ This app also demonstraits how you can implement you own UI for the RFID reading process. To enable it, change the `useRfidSelfHostedUI` constant to true in `src/extra/custom_rfid`. Run the app and initiate RFID reading.
@@ -4,6 +4,7 @@
4
4
  <name>DocumentReader</name>
5
5
  <icon src="src/images/icon.png" />
6
6
  <platform name="android">
7
+ <resource-file src="src/assets/db.dat" target="app/src/main/assets/Regula/db.dat"/>
7
8
  <preference name="orientation" value="portrait" />
8
9
  <preference name="android-minSdkVersion" value="24" />
9
10
  <preference name="android-targetSdkVersion" value="35" />
@@ -17,6 +18,7 @@
17
18
  </edit-config>
18
19
  </platform>
19
20
  <platform name="ios">
21
+ <resource-file src="src/assets/db.dat" />
20
22
  <preference name="orientation" value="portrait" />
21
23
  <allow-intent href="itms:*" />
22
24
  <allow-intent href="itms-apps:*" />
@@ -0,0 +1,54 @@
1
+ import 'zone.js';
2
+ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
3
+ import { BrowserModule } from '@angular/platform-browser'
4
+ import { IonicModule, Platform } from '@ionic/angular'
5
+ import { NgModule } from '@angular/core'
6
+
7
+ import { Component } from '@angular/core'
8
+ import { File } from '@awesome-cordova-plugins/file'
9
+ import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera/ngx'
10
+
11
+ import { main } from './src/main'
12
+
13
+ export async function loadAsset(path: string): Promise<string> {
14
+ var dir = await File.resolveDirectoryUrl(File.applicationDirectory + "www/assets")
15
+ var fileEntry = await File.getFile(dir, path, null)
16
+ var result = await new Promise<string>((resolve, _) => {
17
+ fileEntry.file(file => {
18
+ var reader = new FileReader()
19
+ reader.onloadend = (_) => resolve(reader.result as string)
20
+ reader.readAsDataURL(file)
21
+ })
22
+ })
23
+ return result
24
+ }
25
+
26
+ export async function pickImage(): Promise<string | null> {
27
+ return await cameraInstance.getPicture({
28
+ destinationType: DestinationType.DATA_URL,
29
+ mediaType: MediaType.PICTURE,
30
+ sourceType: PictureSourceType.PHOTOLIBRARY
31
+ })
32
+ }
33
+
34
+ var cameraInstance: Camera
35
+ @Component({
36
+ selector: 'app-root',
37
+ templateUrl: 'src/main.html',
38
+ styleUrl: 'src/main.css'
39
+ })
40
+ class Main {
41
+ constructor(platform: Platform, camera: Camera) {
42
+ cameraInstance = camera
43
+ platform.ready().then(main)
44
+ }
45
+ }
46
+
47
+ @NgModule({
48
+ bootstrap: [Main],
49
+ providers: [Platform, Camera],
50
+ imports: [BrowserModule, IonicModule.forRoot()]
51
+ })
52
+ class MainModule { }
53
+
54
+ platformBrowserDynamic().bootstrapModule(MainModule)
@@ -6,9 +6,9 @@
6
6
  "android": "scripts/android.sh"
7
7
  },
8
8
  "dependencies": {
9
- "@regulaforensics/document-reader": "8.2.204-beta",
10
- "@regulaforensics/document-reader-core-fullauthrfid": "8.2.8-beta",
11
- "@regulaforensics/document-reader-btdevice": "8.2.8-beta",
9
+ "@regulaforensics/document-reader": "8.3.246-beta",
10
+ "@regulaforensics/document-reader-core-fullauthrfid": "8.3.9-beta",
11
+ "@regulaforensics/document-reader-btdevice": "8.3.10-beta",
12
12
  "@awesome-cordova-plugins/file": "6.14.0",
13
13
  "@awesome-cordova-plugins/camera": "6.14.0",
14
14
  "cordova-ios": "7.1.1",