Skip to main content

Page Model | Flutter Document Scanner

Page Model

All SDK components (UI and non-UI) which generate or modify scanned documents use the notion of a Page as a data model.

A Page object represents a scanned document page and has the following fields:

Page (
String pageId;
List<PolygonPoint>? polygon;
DetectionStatus? detectionStatus;
ImageFilterType? filter;
Size? documentImageSizeLimit;
Uri? originalImageFileUri;
Uri? documentImageFileUri;
Uri? originalPreviewImageFileUri;
Uri? documentPreviewImageFileUri;

The fields are:

  • pageId - a unique, random string (UUID) identifying the page in the internal page file storage.
  • polygon - the page's cropping polygon as calculated by a document detection operation or as set by the cropping UI. Modifying the polygon will change the polygon as shown in the cropping UI but will not automatically re-crop the original image.
  • detectionStatus - the detection status of the document detection operation that produced the page (either the document scanner or detectDocument()).
  • filter - the image filter type which was applied on the document image of this page.
  • documentImageSizeLimit - limits the maximum resolution (width, height) of the document image. If null is passed, this property is effectively ignored. If specified, width and height must be > 0.
  • originalImageFileUri - file URI of the original image.
  • documentImageFileUri - file URI of the cropped document image (if document detection was successful).
  • originalPreviewImageFileUri - file URI of a screen-sized preview of the original image.
  • documentPreviewImageFileUri - file URI of a screen-sized preview of the document image.

Pages are stored in an internal page file storage, where the pageId serves as a name prefix for the stored image files. Operations that modify pages work in-place. That is, for example, rotatePageClockwise() overwrites the page's image files with their rotated versions.


The Scanbot SDK polygon is a list with 4 float points (one for each corner). Each point has coordinates in the range [0..1], representing a position relative to the image size. For instance, if a point has the coordinates (0.5, 0.5), it means that it is located exactly in the center of the image.

Example code of a detected polygon as dart result:

var polygon = [

Detection Status values


  • DetectionStatus.OK - Document detection was successful. The detected contour looks like a valid document.
  • DetectionStatus.OK_BUT_BAD_ANGLES - Document was detected, but the perspective is not ideal.
  • DetectionStatus.OK_BUT_BAD_ASPECT_RATIO - Document was detected, but it has a wrong rotation relative to the camera sensor.
  • DetectionStatus.OK_BUT_TOO_SMALL - Document was detected, but it does not fill the desired area in the image rect.
  • DetectionStatus.ERROR_TOO_DARK - Document was not found, most likely due to bad lighting conditions.
  • DetectionStatus.ERROR_TOO_NOISY - Document was not found, most likely due to too much background noise (maybe too many other objects on the table, or background texture is not monotonic).
  • DetectionStatus.ERROR_NOTHING_DETECTED - No document was found.

Image Filter values

Supported image filters:

  • COLOR_ENHANCED - Optimizes colors, contrast and brightness.
  • GRAYSCALE - Grayscale filter.
  • BINARIZED - Standard binarization filter with contrast optimization. Creates an 8-bit grayscale image with mostly black or white pixels.
  • COLOR_DOCUMENT - MagicColor filter. Fixes white balance and cleans up the background.
  • PURE_BINARIZED - A filter for binarizing an image. Creates an image with pixel values set to either pure black or pure white.
  • BACKGROUND_CLEAN - Cleans up the background and tries to preserve photos within the image.
  • BLACK_AND_WHITE - Black and white filter with background cleaning. Creates an 8-bit grayscale image with mostly black or white pixels.
  • OTSU_BINARIZATION - A filter for black and white conversion using OTSU binarization.
  • DEEP_BINARIZATION - A filter for black and white conversion primary used for low-contrast documents.
  • EDGE_HIGHLIGHT - A filter that enhances edges in low-contrast documents.
  • LOW_LIGHT_BINARIZATION - Binarization filter primary intended to use on low-contrast documents with heavy shadows.
  • LOW_LIGHT_BINARIZATION_2 - Binarization filter primary intended to use on low-contrast documents with heavy shadows.

Persistence of Page Objects

Scanbot SDK does not persist page objects, only the image files (.jpg or .png). The management of page objects and the persistence of the page metadata is left to the app. Depending on the use case, it may be necessary to persist the data of the page objects in the app (e.g. as JSON in a local SQLite database). If this is the case, the following must be considered.

The Page objects contain absolute paths to the image files:

"pageId": "60426F47-4119-48F8-ADA9-F7E60D583CB4",
"filter": "NONE",
"detectionResult": "OK",
"polygon": [{"x":0.17427248677248677,"y":0.1212797619047619},{"x":0.8604497354497355,"y":0.13120039682539678},{"x":0.8349867724867724,"y":0.9729662698412699},{"x":0.12202380952380967,"y":0.9471726190476191}],
"documentPreviewImageFileUri": "file:///var/mobile/Containers/Data/Application/54286F82-A8F7-4850-A684-8D3487726A4D/Library/Application%20Support/net.doo.ScanbotSDK/SBSDK_ImageStorage_Default/PageFileStorage/JPEG/documents/60426F47-4119-48F8-ADA9-F7E60D583CB4_preview.jpg?minihash=a236a8ba5510cd0f4e88bd2045f52c4e",
"originalImageFileUri": "file:///var/mobile/Containers/Data/Application/54286F82-A8F7-4850-A684-8D3487726A4D/Library/Application%20Support/net.doo.ScanbotSDK/SBSDK_ImageStorage_Default/PageFileStorage/JPEG/originals/60426F47-4119-48F8-ADA9-F7E60D583CB4.jpg?minihash=4e9f0446421343eaaa1e415fdb446a12",
"originalPreviewImageFileUri": "file:///var/mobile/Containers/Data/Application/54286F82-A8F7-4850-A684-8D3487726A4D/Library/Application%20Support/net.doo.ScanbotSDK/SBSDK_ImageStorage_Default/PageFileStorage/JPEG/originals/60426F47-4119-48F8-ADA9-F7E60D583CB4_preview.jpg?minihash=da888cd42db07e52b15a6ada29a37b63",
"documentImageFileUri": "file:///var/mobile/Containers/Data/Application/54286F82-A8F7-4850-A684-8D3487726A4D/Library/Application%20Support/net.doo.ScanbotSDK/SBSDK_ImageStorage_Default/PageFileStorage/JPEG/documents/60426F47-4119-48F8-ADA9-F7E60D583CB4.jpg?minihash=f9aab62cc37fec555abe94c83406a1b3"

The page image files are stored in corresponding storage locations - also see the Storage section. By default, the Scanbot SDK Android uses the internal files directory of the app, whereas the Scanbot SDK iOS uses the "Application Support" folder. Those storage folders are secure and are not affected by an app update.

However, on iOS, the absolute file path of the "Application Support" folder is not reliable. For each fresh install of an app, a new UUID is generated, in the following format: /var/mobile/Containers/Data/Application/{UUID}. This is where application data is stored. When updating the app, the uuid may change. For example:

Before an app update:


After the app update:


Please note that the actual image files are still there, only their absolute file paths have changed.

To obtain the new absolute paths, the API method refreshImageUris(pages) has been introduced in the plugin version 2.1.0. Please use this method to refresh all image file URIs for affected pages:

List<Page> loadedPages = ... // load page objects from DB
var refreshedPages = await ScanbotSdk.refreshImageUris(loadedPages);

It is highly recommended using this method whenever you have to (re-)load Page objects from the database of your app, regardless of whether there was an app update or not.

Want to scan longer than one minute?

Generate a free trial license to test the Scanbot SDK thoroughly.

Get your free Trial License

What do you think of this documentation?