# Class: DocumentNormalizerView

[Mobile Document Scanner API Reference](../index.md) / DocumentNormalizerView

# Class: DocumentNormalizerView

Defined in: [src/views/DocumentCorrectionView.ts:191](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/src/views/DocumentCorrectionView.ts#L191)

## Constructors

### Constructor

> **new DocumentNormalizerView**(`resources`, `config`, `scannerView?`): `DocumentCorrectionView`

Defined in: [src/views/DocumentCorrectionView.ts:222](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/src/views/DocumentCorrectionView.ts#L222)

#### Parameters

##### resources

`SharedResources`

##### config

[`DocumentCorrectionViewConfig`](../interfaces/DocumentCorrectionViewConfig.md)

##### scannerView?

[`DocumentScannerView`](DocumentScannerView.md)

#### Returns

`DocumentCorrectionView`

## Methods

### confirmCorrection()

> **confirmCorrection**(): `Promise`\<`void`\>

Defined in: [src/views/DocumentCorrectionView.ts:839](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/src/views/DocumentCorrectionView.ts#L839)

Confirm the boundary adjustments and apply perspective correction to the image.

#### Returns

`Promise`\<`void`\>

#### Throws

If no quadrilateral boundary is found on the drawing layer

#### Remarks

Retrieves boundary, performs correction via [correctImage](#correctimage), updates result, invokes callback, resolves promise.

***

### correctImage()

> **correctImage**(`points`): `Promise`\<`DeskewedImageResultItem` \| `undefined`\>

Defined in: [src/views/DocumentCorrectionView.ts:927](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/src/views/DocumentCorrectionView.ts#L927)

Apply perspective correction to the document image using Dynamsoft Document Normalizer (DDN).

#### Parameters

##### points

\[`Point`, `Point`, `Point`, `Point`\]

The quadrilateral corner points defining the document boundary

#### Returns

`Promise`\<`DeskewedImageResultItem` \| `undefined`\>

The perspective-corrected (deskewed) image, or undefined if correction fails

#### Remarks

Configures ROI with quadrilateral points, processes image with normalization template.

***

### dispose()

> **dispose**(`preserveResolver?`): `void`

Defined in: [src/views/DocumentCorrectionView.ts:963](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/src/views/DocumentCorrectionView.ts#L963)

Clean up and release resources.

#### Parameters

##### preserveResolver?

`boolean` = `false`

Whether to preserve the `currentCorrectionResolver` promise resolver

#### Returns

`void`

#### Remarks

Disposes [ImageEditorView](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/index.html), clears layer and container. Optionally preserves resolver for `handleRetake`.

***

### hideView()

> **hideView**(): `void`

Defined in: [src/views/DocumentCorrectionView.ts:911](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/src/views/DocumentCorrectionView.ts#L911)

Hide the correction view by setting its container display to "none".

#### Returns

`void`

#### Remarks

Sets container display to "none" without disposing resources.

***

### initialize()

> **initialize**(): `Promise`\<`void`\>

Defined in: [src/views/DocumentCorrectionView.ts:233](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/src/views/DocumentCorrectionView.ts#L233)

#### Returns

`Promise`\<`void`\>

***

### launch()

> **launch**(): `Promise`\<[`DocumentResult`](../interfaces/DocumentResult.md)\>

Defined in: [src/views/DocumentCorrectionView.ts:870](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/src/views/DocumentCorrectionView.ts#L870)

#### Returns

`Promise`\<[`DocumentResult`](../interfaces/DocumentResult.md)\>

***

### setBoundaryAutomatically()

> **setBoundaryAutomatically**(): `Promise`\<`void`\>

Defined in: [src/views/DocumentCorrectionView.ts:796](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/src/views/DocumentCorrectionView.ts#L796)

Automatically detect document boundaries using Dynamsoft Document Normalizer (DDN).

#### Returns

`Promise`\<`void`\>

#### Remarks

This method re-runs document boundary detection on the current image using the
`CaptureVisionRouter` and DDN (Dynamsoft Document Normalizer) engine. The process:

1. Initializes settings from [DocumentCorrectionViewConfig.templateFilePath](../interfaces/DocumentCorrectionViewConfig.md#templatefilepath) if provided
2. Retrieves the detection template settings via [DocumentCorrectionViewConfig.utilizedTemplateNames](../interfaces/DocumentCorrectionViewConfig.md#utilizedtemplatenames)
3. Configures the router to:
   - Output the original image for further processing
   - Process images at full resolution (no downscaling via `maxImageSideLength = Infinity`)
4. Captures and analyzes the image to detect document boundaries
5. Handles the detection result:
   - **Boundary detected**: Creates a [QuadDrawingItem](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/index.html) from the detected [Quadrilateral](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/index.html)
     and adds it to the layer via `addQuadToLayer`
   - **No boundary detected**: Falls back to [setFullImageBoundary](#setfullimageboundary) to use full image dimensions

This allows users to retry automatic detection if:
- Manual adjustments were made but proved unsatisfactory
- Initial detection failed due to lighting or positioning issues that were later corrected
- The image was uploaded without initial detection

Triggered by clicking the "Detect Borders" button created in `createControls`.

#### See

 - `CaptureVisionRouter` - Processes the image for boundary detection
 - [DetectedQuadResultItem](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/index.html) - Contains the detected document boundaries
 - `addQuadToLayer` - Adds the detected quadrilateral to the drawing layer
 - [setFullImageBoundary](#setfullimageboundary) - Fallback when no boundaries are detected
 - `SharedResources.cvRouter` - The router instance used for detection

***

### setFullImageBoundary()

> **setFullImageBoundary**(): `void`

Defined in: [src/views/DocumentCorrectionView.ts:743](https://github.com/Dynamsoft/document-scanner-javascript/blob/main/src/views/DocumentCorrectionView.ts#L743)

Reset the document boundary to match the full image dimensions.

#### Returns

`void`

#### Throws

If no captured image is available in `SharedResources.result`

#### Remarks

This method creates a quadrilateral boundary that encompasses the entire image, effectively
disabling perspective correction. The quadrilateral corners are positioned at:
- Top-left: (0, 0)
- Top-right: (width, 0)
- Bottom-right: (width, height)
- Bottom-left: (0, height)

This is useful when:
- The document occupies the entire image with no background visible
- Automatic boundary detection failed or detected incorrect boundaries
- Users want to skip perspective correction and use the original image dimensions

The created quadrilateral is added to the [DrawingLayer](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/index.html) via `addQuadToLayer`,
replacing any existing boundary. Users can still manually adjust the corners after reset.

Triggered by clicking the "Full Image" button created in `createControls`.

#### See

 - `SharedResources.result` - Contains the original image dimensions
 - [QuadDrawingItem](https://www.dynamsoft.com/capture-vision/docs/web/programming/javascript/api-reference/index.html) - The quadrilateral type added to the drawing layer
 - `addQuadToLayer` - Adds the full-image quadrilateral to the layer
 - [setBoundaryAutomatically](#setboundaryautomatically) - Alternative method for automatic boundary detection
