Skip to main content

Page Operations | Flutter Document Scanner

Create page

Future<Page> createPage(
Uri originalImageFileUri,
bool shouldDetectDocument, {
Size? originalImageSizeLimit,
Size? documentImageSizeLimit,
})

Creates a page object from an image. If the encryption parameters are set during the SDK initialization, then the page's images will be stored encrypted with given parameters.

Uri originalImageFileUri = ... // "file:///some/image.jpg"
var page = await ScanbotSdk.createPage(originalImageFileUri, true);
  • originalImageFileUri - the file URI of the original image to create a page and optionally run document detection on.
  • shouldDetectDocument - flag to specify whether the auto document detection should be performed and the (cropped) DOCUMENT image should be created.

Create page with image bytes

Future<Page> createPageWithImageBytes(
Uint8List imageBytes,
bool shouldDetectDocument, {
Size? originalImageSizeLimit,
Size? documentImageSizeLimit,
})

Creates a page from image bytes. The given image will be used as the ORIGINAL image.

Use the shouldDetectDocument flag to specify whether the auto-document detection should be performed and the (cropped) DOCUMENT image should be created.
originalImageSizeLimit sets the maximum size of the original image to be saved. If the original image is larger than the specified size it will be downscaled. By default, not specified.
documentImageSizeLimit sets the maximum size of the cropped document image to be saved. If the image is larger than the specified size it will be downscaled. If originalImageSizeLimit is set it also limits the size of the cropped document image. By default, not specified.

Uint8List imageBytes = [...]
var page = await ScanbotSdk.createPageWithImageBytes(originalImageFileUri, true);
  • imageBytes - the image bytes to create a page and optionally run document detection on.
  • shouldDetectDocument - flag to specify whether the auto document detection should be performed and the (cropped) DOCUMENT image should be created.

Detect document on page

Future<Page> detectDocument(Page page)

Performs auto document detection on the ORIGINAL image of the given page and creates a (cropped) DOCUMENT image. The given page must contain the ORIGINAL image.

var updatedPage = await ScanbotSdk.detectDocument(page);
  • page - a valid page object with an original image to process.

Delete page

Future<void> deletePage( Page page )

Removes a page with all its files (ORIGINAL image, DOCUMENT image, previews/thumbnails, filtered images, etc) from the file storage of the Scanbot SDK. This method does not remove any exported files (PDF, TIFF, etc) which were generated based on this page object.

await ScanbotSdk.deletePage(page);
  • page - a valid page object to process.

Apply Image Filter

Future<Page> applyImageFilter( Page page, List<ParametricFilter> filters )

Applies an image filter on the cropped DOCUMENT image of a page.

var updatedPage = await ScanbotSdk.applyImageFilter(page, [ScanbotBinarizationFilter()]);
  • page - a valid page object with a DOCUMENT image.
  • filters - the image filters to apply. The special value ImageFilterType.NONE of LegacyFilter will remove any previously applied filter from the document image.

Rotate page clockwise

Future<Page> rotatePageClockwise(Page page, int rotationsCount)

Rotates all images of the given page by 90 degrees for rotationsCount times.

var updatedPage = await ScanbotSdk.rotatePageClockwise(page, 2);
  • page - the page to rotate.
  • rotationsCount - the number of clockwise rotations to apply.

Refresh Image URI's

Future<List<Page>> refreshImageUris(List<Page> pages)

Refreshes image file URI's of provided pages.

var refreshPages = await ScanbotSdk.refreshImageUris(pages);
  • pages - a valid page objects.

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?