Straightening documents with the iOS Document Scanner
The Document Enhancer can straighten scanned documents by removing paper deformations such as creases, curl, folds, and crinkles, and correcting perspective distortion.
It supports two straightening modes:
| Mode | Description |
|---|---|
NONE | Crops the document based on estimated perspective distortion. Very fast. |
STRAIGHTEN | Removes paper deformations in addition to perspective correction. |
Document straightening is available across multiple integration points in the Scanbot SDK, allowing flexibility depending on your workflow.
You can use it:
- As part of the Ready-to-Use (RTU) Document Scanner UI for automatic processing during capture
- On individual scanned pages for manual or selective post-processing
- Via the Document API for full programmatic control and custom pipelines
Usage in the RTU UI Document Scanner
The document straightening can be configured in the RTU UI Document Scanner.
By default, the captured document pages are automatically straightened. The result includes the straightening parameters applied to the page. When disabled, the cropped images are returned without straightening applied.
loading...
Straightening a scanned page
A scanned page can be straightened directly for more control.
- Straighten after capture
- Re-process existing pages
- Keep original and processed versions
This allows flexible integration into custom review and editing workflows.
loading...
Straightening an image
You can also straighten an image directly using the DocumentEnhancer API, providing full control over the enhancement process.
loading...
Configuration options
The DocumentStraighteningParameters class provides the following options:
| Parameter | Type | Default | Description |
|---|---|---|---|
straighteningMode | DocumentStraighteningMode | STRAIGHTEN | The type of straightening to apply. |
aspectRatios | AspectRatio[] | Empty | Expected aspect ratios for the document. The closest matching ratio from the list is used. |
Aspect ratios
By default, the aspect ratio of the straightened document is automatically determined from the detected document corners. If the document is significantly deformed, the estimated aspect ratio may be inaccurate.
In such cases, you can provide a list of expected aspect ratios to improve accuracy. Note that if you want to support both portrait and landscape orientations for a given paper format, you need to provide both aspect ratios (e.g., AspectRatio(21.0, 29.7) and AspectRatio(29.7, 21.0) for A4 paper).
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get free trial licenseScanbot SDK is part of the Apryse SDK product family
A mobile scan is just the start. With Apryse SDKs, you can expand mobile workflows into full cross‑platform document processing. Whether you need to edit PDFs, add secure digital signatures, or use a fast, customizable document viewer and editor, Apryse gives you the tools to build powerful features quickly.
Learn more
