|
| 1 | +--- |
| 2 | +layout: default-layout |
| 3 | +needAutoGenerateSidebar: true |
| 4 | +needGenerateH3Content: true |
| 5 | +noTitleIndex: false |
| 6 | +breadcrumbText: Angular Guide |
| 7 | +title: Mobile Document Scanner JS Edition - Angular |
| 8 | +keywords: Documentation, Mobile Document Scanner, Web, JS Edition, Dynamsoft Document Scanner, Angular |
| 9 | +description: Mobile Document Scanner JS Edition Angular User Guide |
| 10 | +--- |
| 11 | + |
| 12 | +# Mobile Document Scanner - Angular |
| 13 | + |
| 14 | +> [!IMPORTANT] |
| 15 | +> This article builds on the prerequisite [MDS developer guide]({{ site.guide }}index.html) for plain JavaScript; please read it before proceeding. |
| 16 | +
|
| 17 | +Mobile Document Scanner integrates easily with Angular applications. Just as in plain JavaScript, you can add document scanning in your **Angular application** in just a few lines of code, and achieve most customizations through the same accessible configuration object. |
| 18 | + |
| 19 | +## Features |
| 20 | + |
| 21 | +- Easy integration with pre-built UI |
| 22 | +- Render MDS inside an Angular component |
| 23 | +- **Standalone components** (modern Angular architecture) |
| 24 | +- Capture and process documents from video stream |
| 25 | +- Automatic document detection and cropping |
| 26 | +- Mobile-optimized scanning interface |
| 27 | +- TypeScript support with type definitions |
| 28 | + |
| 29 | +## Requirements |
| 30 | + |
| 31 | +- **Node.js 20.19.0 or later** |
| 32 | +- [Base requirements]({{ site.introduction }}index.html#system-requirements) |
| 33 | + |
| 34 | +## License |
| 35 | + |
| 36 | +### Get a Trial License |
| 37 | + |
| 38 | +Try **MDS** by requesting a trial license through our [customer portal](https://www.dynamsoft.com/customer/license/trialLicense?product=mwc&utm_source=github_angular_readme). You can renew the license twice for up to a total of two months of free access. |
| 39 | + |
| 40 | +### Get a Full License |
| 41 | + |
| 42 | +[Contact us](https://www.dynamsoft.com/company/contact?product=mwc&utm_source=github_angular_readme) to purchase a full license. |
| 43 | + |
| 44 | +## Quick Start |
| 45 | + |
| 46 | +We publish **MDS** library files on [npm](https://www.npmjs.com/package/dynamsoft-document-scanner) to make them simple to reference from a CDN. We reference the library files in our _ready-made_ Hello World sample for Angular included in our GitHub source repository: |
| 47 | + |
| 48 | +1. Download **MDS** from [GitHub](https://github.com/Dynamsoft/document-scanner-javascript) as a compressed folder. |
| 49 | + |
| 50 | +2. Extract the contents of the archive, and open the extracted directory in a code editor. |
| 51 | + |
| 52 | +3. Set your [license key](#get-a-trial-license) in the **Angular framework sample**: |
| 53 | + 1. Open the sample at [`/samples/frameworks/angular/src/app/app.component.ts`](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/document-scanner-javascript-dev/samples/frameworks/angular/src/app/app.component.ts). |
| 54 | + 2. Search for `"YOUR_LICENSE_KEY_HERE"`, then replace it with your actual license key. |
| 55 | + |
| 56 | +### Install Dependencies |
| 57 | + |
| 58 | +```bash |
| 59 | +npm install |
| 60 | +``` |
| 61 | + |
| 62 | +### Start the App |
| 63 | + |
| 64 | +```bash |
| 65 | +ng serve |
| 66 | +``` |
| 67 | + |
| 68 | +> [!TIP] |
| 69 | +> If you installed Angular locally, you can call the local version with |
| 70 | +> ```shell |
| 71 | +> npx ng serve |
| 72 | +> ``` |
| 73 | +
|
| 74 | +Open `http://localhost:4200/` to view the sample app. |
| 75 | +
|
| 76 | +> [!NOTE] |
| 77 | +> Secure context requires HTTPS to provide camera access, but Angular CLI serves over HTTP by default. For mobile testing, you may need to configure HTTPS or use a reverse proxy. |
| 78 | +
|
| 79 | +## Self-Host Resources |
| 80 | +
|
| 81 | +You can self host the resources for the Hello World by following a few simple steps. Refer to the [plain JavaScript self-hosting guide]({{ site.guide }}index.html#quick-start) for details. |
| 82 | +
|
| 83 | +### Set File Paths |
| 84 | +
|
| 85 | +First we set MDS to look resource paths where we will place the resources later: |
| 86 | +
|
| 87 | +```typescript |
| 88 | +const documentScanner = new Dynamsoft.DocumentScanner({ |
| 89 | + license: "YOUR_LICENSE_KEY_HERE", |
| 90 | + scannerViewConfig: { |
| 91 | + cameraEnhancerUIPath: "dist/libs/dynamsoft-document-scanner/dist/document-scanner.ui.html", |
| 92 | + }, |
| 93 | + engineResourcePaths: { |
| 94 | + rootDirectory: "dist/libs/" |
| 95 | + }, |
| 96 | +}); |
| 97 | +``` |
| 98 | +
|
| 99 | +### Move Resources |
| 100 | + |
| 101 | +Now, add a script (`get-libs`) to automatically move the resources to their destination when building the project (`build`) in `samples/framework/angular/package.json`: |
| 102 | + |
| 103 | +```json |
| 104 | +"scripts": { |
| 105 | + "ng": "ng", |
| 106 | + "start": "ng serve --ssl", |
| 107 | + "build": "ng build && npm run get-libs", |
| 108 | + "get-libs": "npm install --no-save dynamsoft-capture-vision-data dynamsoft-capture-vision-bundle && npx mkdirp /dist/libs && npx cpx 'node_modules/dynamsoft-*/**/*' dist/libs/ --dereference", |
| 109 | + "watch": "ng build --watch --configuration development", |
| 110 | + "test": "ng test" |
| 111 | +}, |
| 112 | +``` |
| 113 | + |
| 114 | +When building, **swap the build script** from `ng build` to `npm run build`. Continue using `ng serve` to serve the application. |
| 115 | + |
| 116 | +## Customization |
| 117 | + |
| 118 | +Please check the official [documentation]({{ site.guide }}index.html). |
| 119 | + |
| 120 | +## Support |
| 121 | + |
| 122 | +If you have any questions, feel free to contact [Dynamsoft support](https://www.dynamsoft.com/company/contact?product=mwc&utm_source=github_angular_readme). |
0 commit comments