A document scanning plugin for Capacitor using Dynamsoft Document Normalizer
npm install capacitor-plugin-dynamsoft-document-normalizerA document scanning plugin for Capacitor using Dynamsoft Document Normalizer.
For Capacitor v7, use versions >= 4.x.
For Capacitor v6, use versions 3.x.
For Capacitor v5, use versions 1.x and 2.x.
For Capacitor v4, use v0.x.
| Product | Android | iOS | Web |
| ----------- | ----------- | ----------- | ------- |
| Dynamsoft Capture Vision | 3.x | 3.x | 3.x |
* Web
* Android
* iOS
``bash`
npm install capacitor-plugin-dynamsoft-document-normalizer
npx cap sync
* initialize()
* initLicense(...)
* initRuntimeSettingsFromString(...)
* detect(...)
* detectBitmap(...)
* normalize(...)
* detectAndNormalize(...)
* setEngineResourcePaths(...)
* Interfaces
* Enums
`typescript`
initialize() => Promise
--------------------
`typescript`
initLicense(options: { license: string; }) => Promise
| Param | Type |
| ------------- | --------------------------------- |
| options | { license: string; } |
--------------------
`typescript`
initRuntimeSettingsFromString(options: { template: string; }) => Promise
| Param | Type |
| ------------- | ---------------------------------- |
| options | { template: string; } |
--------------------
`typescript`
detect(options: { path?: string; source?: string | HTMLImageElement | HTMLCanvasElement; template?: string; }) => Promise<{ results: DetectedQuadResultItem[]; }>
source: Android and iOS only support base64 string.
path: for Android and iOS.
template: pass a template name to specify the template
| Param | Type |
| ------------- | ---------------------------------------------------------------- |
| options | { path?: string; source?: any; template?: string; } |
Returns: Promise<{ results: DetectedQuadResultItem[]; }>
--------------------
`typescript`
detectBitmap(options: { className?: string; methodName?: string; template?: string; }) => Promise<{ results: DetectedQuadResultItem[]; }>
Android and iOS only method which directly reads camera frames from capacitor-plugin-camera. Pass a template name to specify the template.
| Param | Type |
| ------------- | ---------------------------------------------------------------------------- |
| options | { className?: string; methodName?: string; template?: string; } |
Returns: Promise<{ results: DetectedQuadResultItem[]; }>
--------------------
`typescript`
normalize(options: { path?: string; source?: string | HTMLImageElement | HTMLCanvasElement; quad: Quadrilateral; template?: string; saveToFile?: boolean; includeBase64?: boolean; }) => Promise<{ result: NormalizedImageResult; }>
source: Android and iOS only support base64 string.
path: for Android and iOS.
template: pass a template name to specify the template
| Param | Type |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| options | { path?: string; source?: any; quad: Quadrilateral; template?: string; saveToFile?: boolean; includeBase64?: boolean; } |
Returns: Promise<{ result: NormalizedImageResult; }>
--------------------
`typescript`
detectAndNormalize(options: { path?: string; source?: string | HTMLImageElement | HTMLCanvasElement; template?: string; saveToFile?: boolean; includeBase64?: boolean; }) => Promise<{ result: NormalizedImageResult; }>
source: Android and iOS only support base64 string.
path: for Android and iOS.
template: pass a template name to specify the template
| Param | Type |
| ------------- | --------------------------------------------------------------------------------------------------------------- |
| options | { path?: string; source?: any; template?: string; saveToFile?: boolean; includeBase64?: boolean; } |
Returns: Promise<{ result: NormalizedImageResult; }>
--------------------
`typescript`
setEngineResourcePaths(options: { paths: any; }) => Promise
Web Only
| Param | Type |
| ------------- | ---------------------------- |
| options | { paths: any; } |
--------------------
#### DetectedQuadResultItem
| Prop | Type | Description |
| ---------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| location | Quadrilateral | The location of the detected quadrilateral within the original image, represented as a quadrilateral shape. |
| confidenceAsDocumentBoundary | number | A confidence score related to the detected quadrilateral's accuracy as a document boundary. |
| CrossVerificationStatus | EnumCrossVerificationStatus | Indicates whether the DetectedQuadResultItem has passed corss verification. |
#### Quadrilateral
| Prop | Type | Description |
| ------------------ | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| points | [Point, Point, Point, Point] | An array of four Point objects defining the vertices of the quadrilateral. |
| boundingRect | DSRect | The bounding rectangle of the quadrilateral, represented by a DSRect object. |
| area | number | The area of the quadrilateral. |
#### Point
| Prop | Type | Description |
| ------- | ------------------- | ------------------------------ |
| x | number | The x-coordinate of the point. |
| y | number | The y-coordinate of the point. |
#### DSRect
| Prop | Type | Description |
| ---------------------------- | -------------------- | ------------------------------------------------------------- |
| left | number | The left coordinate of the rectangle. |
| right | number | The right coordinate of the rectangle. |
| top | number | The top coordinate of the rectangle. |
| bottom | number | The bottom coordinate of the rectangle. |
| isMeasuredInPercentage | boolean | Indicates if the rectangle's measurements are in percentages. |
#### NormalizedImageResult
| Prop | Type |
| ------------ | ------------------- |
| base64 | string |
| path | string |
#### EnumCrossVerificationStatus
| Members | Value | Description |
| ---------------------- | -------------- | ---------------------------------------------------- |
| CVS_NOT_VERIFIED | 0 | The cross verification has not been performed yet. |
| CVS_PASSED | 1 | The cross verification has been passed successfully. |
| CVS_FAILED` | 2 | The cross verification has failed. |