You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guide/index.md
+38-33Lines changed: 38 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,7 +163,11 @@ Alternatively, you can use other methods like `IIS` or `Apache` to serve the pro
163
163
164
164
### Self-Host Resources
165
165
166
-
By default, the MDS library (whether pre-compiled or self-compiled) fetches resource files (Dynamsoft `node` dependencies and an HTML UI template) from CDNs. Self-hosting library resources gives you full control over hosting your application. Rather than using CDNs to serve these resources, you can instead host these resources on your own servers to deliver to your users directly when they use your application. You can also use this option to host MDS fully offline by pointing to local resources.
166
+
By default, the MDS library (whether pre-compiled or self-compiled) fetches resource files (Dynamsoft `node` dependencies and an HTML UI template) from CDNs. Self-hosting library resources gives you full control over hosting your application. Rather than using CDNs to serve these resources, you can instead host these resources on your own servers to deliver to your users directly when they use your application. You can also use this option to host MDS fully offline by pointing to local resources. Here are the resources to self-host:
167
+
168
+
1. `document-scanner.ui.xml` - the UI template for the `DocumentScannerView`/viewfinder.
169
+
2. `dynamsoft-capture-vision-bundle` - the `node` package for the Dynamsoft Capture Vision (DCV) engine resources.
170
+
3. `dynamsoft-capture-vision-data` - the `node` package for DCV engine configuration templates.
167
171
168
172
#### Download Resources
169
173
@@ -174,19 +178,37 @@ First, download a copy of the resources:
174
178
2. Extract the contents of the archive, and open the extracted directory in a code editor.
175
179
176
180
3. Set your [license key](#get-a-trial-license) in the Hello World sample:
177
-
1. Open the Hello World sample at ([`/samples/hello-world.html`](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/samples/hello-world.html)).
178
181
179
-
2. Search for`"YOUR_LICENSE_KEY_HERE"`, then replace it with your actual license key.
182
+
1. Open the Hello World sample at ([`/samples/hello-world.html`](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/samples/hello-world.html)).
183
+
184
+
2. Search for`"YOUR_LICENSE_KEY_HERE"`, then replace it with your actual license key.
180
185
181
186
4. In the terminal, navigate to the project root directory and run the following to install project dependencies:
> We install `dynamsoft-capture-vision-data` as MDS does not use it as a build dependency.
195
+
196
+
#### Modify the Build Script
197
+
198
+
Add a script by updating the `scripts` property in`package.json` that automatically copies the two `node` dependencies to the output `dist` directory during the build process. We will configure MDS to request the resources here.
The library uses [`engineResourcePaths`]({{ site.api }}index.html#engineresourcepaths) to locate required Dynamsoft `node` dependencies by pointing to the location of the resources on your web server. The library also uses `scannerViewConfig.cameraEnhancerUIPath` similarly to set the path forthe HTML UI template of the `ScannerView`. Later steps will place both the `node` dependencies and the HTML templatein the local`dist` directory. Therefore, set`engineResourcePaths`in the MDS constructor to point to the local`dist` directory (along with setting your license key, and all other configurations):
211
+
The library uses [`engineResourcePaths`](https://www.dynamsoft.com/mobile-document-scanner/docs/web/api/index.html#engineresourcepaths) to locate required Dynamsoft `node` dependencies by pointing to the location of the resources on your web server. The library also uses `scannerViewConfig.cameraEnhancerUIPath` similarly to set the path forthe HTML UI template of the `ScannerView`.Therefore, set `engineResourcePaths`in the MDS constructor to point to the local`dist` directory, where the resources are located (along with setting your license key, and all other configurations):
190
212
191
213
```javascript
192
214
const documentScanner = new Dynamsoft.DocumentScanner({
@@ -195,12 +217,8 @@ const documentScanner = new Dynamsoft.DocumentScanner({
195
217
cameraEnhancerUIPath: "./dist/document-scanner.ui.xml", // Use the local file
Update the `scripts` section in`package.json` to automatically copy resources to the output `dist` directory during the build process. This script gets the `dynamsoft-capture-vision-data` package, and moves both `dynamsoft-capture-vision-data` and `dynamsoft-capture-vision-bundle` to `dist/libs/`, which is where we set the resource directory to.
0 commit comments