Angular
Accura IDScan Plugin — Angular Integration Guide
This guide walks you through integrating the Accura IDScan Plugin into an Angular project using standalone components.
Step 1: Initialize Project
Create a new Angular project with standalone component architecture. When prompted, select No for Server-Side Rendering (SSR):
npx ng new my-id-app --standalone
cd my-id-app
npm installAfter scaffolding, open angular.json and ensure SSR and prerendering are explicitly disabled:
"options": {
"prerender": false,
"ssr": false
}Step 2: Install Plugin
Install the Accura IDScan Plugin package from the npm registry:
npm install accuraidscanpluginStep 3: TypeScript Support
Angular enforces strict TypeScript compilation. Create a type declaration file at src/types.d.ts to declare the module and suppress resolution errors:
Ensure this file is included in your tsconfig.app.json's include array:
Step 4: Implementation
Generate the scanner component or create it manually at src/app/id-scanner/id-scanner.component.ts. The snippet below shows only the plugin import and instantiation logic:
Step 5: Response Handling
When the plugin completes an ID card scan, it invokes the handleCapture callback with a typed payload object. This object may contain one or both of the following properties:
front
string
Base64 Data URL of the front side of the ID card
back
string
Base64 Data URL of the back side of the ID card (if applicable)
What is Base64? Base64 is a binary-to-text encoding scheme that converts raw binary image data into a sequence of printable ASCII characters. Each scanned card image is delivered as a Data URL string (e.g., data:image/jpeg;base64,/9j/...), combining a MIME type prefix with the encoded image payload. Before transmitting to a server, this string must be decoded back into binary form (a Blob) to construct a valid multipart HTTP request.
The following demonstrates the base64-to-Blob conversion and API submission:
Step 6: Demo Implementation
The following is the complete, production-ready component. Copy and paste it directly into src/app/id-scanner/id-scanner.component.ts. The original logic is preserved exactly as-is.
Step 7: Usage
Register and render the component in app.component.ts:
Step 8: Running the Project
Last updated