@docutain/react-native-docutain-sdk
Version:
React Native plugin of the Docutain Document Scanner SDK for Android and iOS. High quality document scanning, data extraction, text recognition and PDF creation for your apps. Easily scan documents in your app.
849 lines (826 loc) • 24.3 kB
text/typescript
/**
* Docutain SDK React Native
* Copyright (c) INFOSOFT Informations- und Dokumentationssysteme GmbH. All rights reserved.
*
* Docutain SDK React Native is a commercial product and requires a license.
* Details found in the LICENSE file in the root directory of this source tree.
*/
/**
* Available PDF page formats when generating PDF documents.
*/
export enum PDFPageFormat {
FIT_TO_PAGES = 'FIT_TO_PAGES',
A4 = 'A4',
A4_LANDSCAPE = 'A4_LANDSCAPE',
A5 = 'A5',
A5_LANDSCAPE = 'A5_LANDSCAPE',
LETTER = 'LETTER',
LETTER_LANDSCAPE = 'LETTER_LANDSCAPE',
LEGAL = 'LEGAL',
LEGAL_LANDSCAPE = 'LEGAL_LANDSCAPE',
}
/**
* Logs can be filtered based on their priority.
*/
export enum LogLevel {
DISABLE = 'DISABLE',
ASSERT = 'ASSERT',
ERROR = 'ERROR',
WARNING = 'WARNING',
INFO = 'INFO',
DEBUG = 'DEBUG',
VERBOSE = 'VERBOSE',
}
/**
* Available filters that can be applied on scanned documents.
*/
export enum ScanFilter {
AUTO = 'AUTO',
GRAY = 'GRAY',
BLACKWHITE = 'BLACKWHITE',
ORIGINAL = 'ORIGINAL',
TEXT = 'TEXT',
AUTO2 = 'AUTO2',
ILLUSTRATION = 'ILLUSTRATION',
}
/**
* Available sources for the document scanner.
*/
export enum Source {
/**
* Scan a document by using the devices camera.
*/
CAMERA = 'CAMERA',
/**
* Scan a document from the provided image.
*/
IMAGE = 'IMAGE',
/**
* Open an image picker in single selection mode and scan a document from the selected image.
*/
GALLERY = 'GALLERY',
/**
* Open an image picker in multi selection mode and scan a document from the selected images.
*/
GALLERY_MULTIPLE = 'GALLERY_MULTIPLE',
/**
* Same as [CAMERA] but shows an additional import button which the user can use to import files as well.
*
*/
CAMERA_IMPORT = 'CAMERA_IMPORT',
}
/**
* Available page source types when generating image files from scanned or imported pages.
*/
export enum PageSourceType {
/**
* Uncut, unfiltered image as delivered by camera.
*/
ORIGINAL = 'ORIGINAL',
/**
* Cut and filtered image.
*/
CUT_FILTER = 'CUT_FILTER',
/**
* Cut only image, no filter.
*/
CUT_ONLY = 'CUT_ONLY',
}
/**
* A configuration class used to alter the default document analysis behaviour.
*/
export interface AnalyzeConfiguration {
/**
* Read BIC.
*/
readBIC?: boolean;
/**
* Read payment state.
*/
readPaymentState?: boolean;
/**
* Read SEPA creditor.
*/
readSEPACreditor?: boolean;
}
/**
* Available statusbar appearances.
*/
export enum StatusBarAppearance {
/**
* Light appearance.
*/
Light = 'LIGHT',
/**
* Dark appearance.
*/
Dark = 'DARK',
}
/**
* Available navigationbar appearances.
*/
export enum NavigationBarAppearance {
/**
* Light appearance.
*/
Light = 'LIGHT',
/**
* Dark appearance.
*/
Dark = 'DARK',
}
/**
* A configuration class used to alter the default page editing behaviour.
*/
export interface PageEditConfiguration {
/**
* If false, the bottom toolbar will hide the filter page item. Defaults to true.
*/
allowPageFilter?: boolean;
/**
* If false, the bottom toolbar will hide the rotate page item. Defaults to true.
*/
allowPageRotation?: boolean;
/**
* If false, the bottom toolbar will hide the arrange page item. Defaults to true.
*/
allowPageArrangement?: boolean;
/**
* If false, the bottom toolbar will hide the page cropping item. Defaults to true.
*/
allowPageCropping?: boolean;
/**
* If true, the bottom toolbar will show a button allowing to retake the current page. Defaults to false.
*/
allowPageRetake?: boolean;
/**
* If true, the bottom toolbar will show a button allowing to add a new page. Defaults to false.
*/
allowPageAdd?: boolean;
/**
* If true, the menu item for deleting pages will be displayed in the toolbar. Defaults to true.
*/
allowPageDeletion?: boolean;
/**
* If true, each item of the page arrangement functionality will show a delete button.
* Defaults to false.
*/
pageArrangementShowDeleteButton?: boolean;
/**
* If true, each item of the page arrangement functionality will show it's page number.
* Defaults to true.
*/
pageArrangementShowPageNumber?: boolean;
}
/**
* A configuration class used to define color in light and dark mode.
*/
export interface DocutainColor {
/**
* Used color in light mode
*/
Light: string;
/**
* Used color in dark mode
*/
Dark: string;
}
/**
* A configuration class used to alter the default color theming behaviour.
*/
export interface ColorConfig {
/**
* is used to tint progress indicators and dialog buttons
*/
ColorPrimary?: DocutainColor;
/**
* is used to tint elements that reside on ColorPrimary, like the icon and text of primary buttons.
*/
ColorOnPrimary?: DocutainColor;
/**
* is used to tint selectable controls and the capture button.
*/
ColorSecondary?: DocutainColor;
/**
* is used to tint elements that reside on docutain_colorSecondary, like the icon of the capture button.
*/
ColorOnSecondary?: DocutainColor;
/**
* is used to tint the background of the layout containing the buttons of the scan layout, like the capture button or torch button.
*/
ColorScanButtonsLayoutBackground?: DocutainColor;
/**
* is used to tint the foreground of the buttons of the scan layout, like the torch button.
*/
ColorScanButtonsForeground?: DocutainColor;
/**
* is used to tint the polygon overlay which highlights the currently detected document.
*/
ColorScanPolygon?: DocutainColor;
/**
* is used to tint the bottom toolbar background of the image editing page.
*/
ColorBottomBarBackground?: DocutainColor;
/**
* is used to tint the buttons within the bottom toolbar of the image editing page.
*/
ColorBottomBarForeground?: DocutainColor;
/**
* is used to tint the top toolbar background.
*/
ColorTopBarBackground?: DocutainColor;
/**
* is used to tint the elements contained in the top toolbar, like buttons and titles.
*/
ColorTopBarForeground?: DocutainColor;
/**
* is used to tint the text of the top toolbar title.
*/
ColorTopBarTitle?: DocutainColor;
}
/**
* A configuration class used to alter the default text behaviour.
*/
export interface TextConfiguration {
/**
* The text size of elements residing in the bottom toolbar. Defaults to 10dp.
*/
textSizeBottomToolbar?: number;
/**
* The text size of menu items residing in the top toolbar.
*/
textSizeTopToolbar?: number;
/**
* The text size of the buttons in the scan page, located at the lower part, like the torch button.
*/
textSizeScanButtons?: number;
/**
* The text size of the title in the top toolbar. By default, auto shrinking down till 9.0 is enabled.
* If you define your custom size, automatic shrinking will be disabled.
*/
textSizeTitle?: number;
/**
* The title to be displayed in the scan page top toolbar.
*/
textTitleScanPage?: string;
/**
* The title to be displayed in the edit page top toolbar.
*/
textTitleEditPage?: string;
/**
* The title to be displayed in the filter page top toolbar.
*/
textTitleFilterPage?: string;
/**
* The title to be displayed in the cropping page top toolbar.
*/
textTitleCroppingPage?: string;
/**
* The title to be displayed in the page arrangement page top toolbar.
*/
textTitleArrangementPage?: string;
/**
* The title to be displayed in the confirmation page top toolbar.
*/
textTitleConfirmationPage?: string;
/**
* The title to show in the top toolbar on all pages. It overwrites page specific titles, if any are set.
*/
textDocumentTitle?: string;
/**
* The text to show in the onboarding popup title that appears when the scan page is opened for the first time.
*
* @deprecated Use `onboarding.scanHintPopup.title'
*/
textOnboardingTitle?: string;
/**
* The text to show in the onboarding popup message that appears when the scan page is opened for the first time.
*
* @deprecated Use `onboarding.scanHintPopup.message'
*/
textOnboardingMessage?: string;
/**
* The text to show in the onboarding popup close button that appears when the scan page is opened for the first time.
*
* @deprecated Use `onboarding.scanHintPopup.closeButton'
*/
textOnboardingCloseButton?: string;
/**
* The text size of the onboarding popup title that appears when the scan page is opened for the first time.
*
* @deprecated removed.
*/
textSizeOnboardingTitle?: number;
/**
* The text size of the onboarding popup message that appears when the scan page is opened for the first time.
*
* @deprecated removed.
*/
textSizeOnboardingMessage?: number;
/**
* The text to show when camera is focusing after capture got triggered.
*/
textFocusHint?: string;
/**
* The text to show when user swipes to previous page but is already at the first page.
*/
textFirstPageHint?: string;
/**
* The text to show when user swipes to next page but is already at the last page.
*/
textLastPageHint?: string;
/**
* The text to show when user swipes to next or previous page but only one page is available.
*/
textOnePageHint?: string;
/**
* The text to show in the progress popup that is shown when user clicks the done button but
* some pages still need to be processed.
*/
textScanProgress?: string;
/**
* The text to show for the option to delete the current page within the dialog that will be
* shown when clicking delete while multiple pages are available.
*/
textDeleteDialogCurrentPage?: string;
/**
* The text to show for the option to delete all pages within the dialog that will be
* shown when clicking delete while multiple pages are available.
*/
textDeleteDialogAllPages?: string;
/**
* The text to show for the option to cancel within the dialog that will be
* shown when clicking delete while multiple pages are available.
*/
textDeleteDialogCancel?: string;
/**
* The title to be displayed in the scan tips page top toolbar.
*/
textTitleScanTipsPage?: string;
}
/**
* A generic button element used for the ready to use UI elements.
*/
export interface DocutainButton {
/**
* The title to show for the button.
*/
title?: string;
/**
* The icon to show for the button.
*/
icon?: string;
}
/**
* A configuration class used to alter the default buttons.
*/
export interface ButtonConfiguration {
/**
* The button that rotates the current page.
*/
buttonEditRotate?: DocutainButton;
/**
* The button that opens the cropping functionality.
*/
buttonEditCrop?: DocutainButton;
/**
* The button that opens the filter functionality.
*/
buttonEditFilter?: DocutainButton;
/**
* The button that opens the page arrangement functionality.
*/
buttonEditArrange?: DocutainButton;
/**
* The button that starts the process of replacing the current page with a new scan.
*/
buttonEditRetake?: DocutainButton;
/**
* The button that deletes the current page or opens a dialog with options if multiple pages
* are available.
*/
buttonEditDelete?: DocutainButton;
/**
* The button that finishes the scan process.
*/
buttonEditFinish?: DocutainButton;
/**
* The button within the cropping functionality that expands the current cropping rectangle
* to the whole page.
*/
buttonCropExpand?: DocutainButton;
/**
* The button within the cropping functionality that snaps the current cropping rectangle
* to the detected document.
*/
buttonCropSnap?: DocutainButton;
/**
* The button within the cropping functionality that finishes the manual cropping process
* according to the current cropping rectangle.
*/
buttonCropFinish?: DocutainButton;
/**
* The button within the scan functionality that is shown when automatic capture is activated.
*/
buttonScanAutoCaptureOn?: DocutainButton;
/**
* The button within the scan functionality that is shown when automatic capture is deactivated.
*/
buttonScanAutoCaptureOff?: DocutainButton;
/**
* The button within the scan functionality that toggles the torch.
*/
buttonScanTorch?: DocutainButton;
/**
* The button within the scan functionality that triggers a manual image capture.
*/
buttonScanCapture?: DocutainButton;
/**
* The button within the scan functionality that finishes the current scan process and leads
* to the editing page.
*/
buttonScanFinish?: DocutainButton;
/**
* The button on the confirmation page that finishes the scan process.
* See [DocumentScannerConfiguration.confirmPages].
*/
buttonConfirmationFinish?: DocutainButton;
/**
* The button on the edit page that opens the scan screen to add a new page.
*/
buttonEditAddPage?: DocutainButton;
/**
* The button on the scan page that opens a file importer.
*/
buttonScanImport?: DocutainButton;
}
/**
* A configuration class used to alter the default scan behaviour.
*/
export interface DocumentScannerConfiguration {
/**
* If true, the toolbar will display an Item allowing the user to switch between auto capture and manual capture. Defaults to false.
*/
allowCaptureModeSetting?: boolean;
/**
* If true, the camera will capture the image automatically at the right moment. Defaults to true.
*/
autoCapture?: boolean;
/**
* The default scan filter that will be used after scan. Defaults to [ScanFilter.ILLUSTRATION]. See [ScanFilter] for possible values.
*/
defaultScanFilter?: ScanFilter;
/**
* Your custom image for the onboarding dialog that appears when scan is opened for the first time.
* @deprecated Use `onboarding.scanHintPopup.imageSource`
*/
onboardingImageSource?: string;
/**
* Configuration class used to alter the default page editing behaviour.
*/
pageEditConfig?: PageEditConfiguration;
/**
* Configuration class used to alter the default color theming behaviour.
*/
colorConfig?: ColorConfig;
/**
* Select the source for the document scanner. Defaults to [Source.CAMERA]. See [Source] for possible values.
*/
source?: Source;
/**
* The source images for the document scanner if you have set the [source] to [Source.IMAGE].
*/
sourceImages?: string[];
/**
* If true, image gets automatically cropped if document was detected. This applies only if
* [source] is [Source.IMAGE] or [Source.GALLERY] or [Source.GALLERY_MULTIPLE]. Defaults to true.
*/
autoCrop?: Boolean;
/**
* If true, scanning multi page documents is possible. Set this to false if you need to scan single page documents. Defaults to true.
*
*/
multiPage?: Boolean;
/**
* If true, the camera will run a focus action right before taking the image. This improves the quality
* of the scanned images, but depending on the device, image capture might take a little bit longer.
* Defaults to true.
*/
preCaptureFocus?: Boolean;
/**
* Configuration class used to alter the default text behaviour.
*/
textConfig?: TextConfiguration;
/**
* Configuration class used to alter the default buttons.
*/
buttonConfig?: ButtonConfiguration;
/**
* If true, a list of all pages (thumbnails) will be displayed before the scan process can be finished.
* Defaults to false.
*/
confirmPages?: Boolean;
/**
* If true, after the scan screen is finished, an editing screen with the captured images will be displayed.
* On the editing screen, the user can crop manually, rotate the page, filter the page and much more.
* The editing screen can be configured by accessing the [pageEditConfig].
* Defaults to true.
*/
allowPageEditing?: Boolean;
/**
* Overrides the status bar appearance. By default, the system chooses the appearance based on the current UI Mode.
*
* Only available on Android.
*
* @since 2.0.5
*/
statusBarAppearance?: StatusBarAppearance;
/**
* Overrides the navigation bar appearance. By default, the system chooses the appearance based on the current UI Mode.
*
* Only available on Android.
*/
navigationBarAppearance?: NavigationBarAppearance;
/**
* If true, when an image is captured, the device vibrates to signal successful capture. Defaults to false.
*/
vibrateOnCapture?: boolean;
/**
* An optional onboarding when the user opens the scanner for the first time. See [Onboarding] for more details.
*/
onboarding?: Onboarding | null;
/**
* An optional toolbar item that shows scan tips when clicked. See [ScanTips] for more details.
*/
scanTips?: ScanTips | null;
}
/**
* A generic list element used for the ready to use UI elements.
*/
export interface DocutainListItem {
/**
* The icon to show for the item.
*/
image?: string;
/**
* The title to show for the item.
*/
title?: string;
/**
* The message to show for the item.
*/
message?: string;
}
/**
* UI components that can be used to onboard the user.
*/
export interface Onboarding {
/**
* The items you want to show within the onboarding. See [DocutainListItem] for more details
* on what each item can display. You can use [defaultItems] if you don't want to provide your own.
* If you want to disable it, set it to null.
*/
items?: DocutainListItem[];
/**
* The button that goes to the next item.
*/
buttonNext?: DocutainButton;
/**
* The button that closes the onboarding on the last item.
*/
buttonFinish?: DocutainButton;
/**
* The button to skip (close) the onboarding.
*/
buttonSkip?: DocutainButton;
/**
* The button that goes to the previous item. It is disabled by default.
*/
buttonBack?: DocutainButton;
/**
* A popup that appears when scan is opened for the first time, explaining the user how to scan.
*/
scanHintPopup?: ScanHintPopup | null;
}
/**
* A popup within the scan screen which shows a short explanation about how to scan.
*/
export interface ScanHintPopup {
/**
* The text to display as title.
*/
title?: string;
/**
* The text to display as message.
*/
message?: string;
/**
* The text of the close button.
*/
closeButton?: string;
/**
* The image to display.
*/
imageSource?: string;
}
/**
* UI components that can be used to provide the user some scan tips.
*/
export interface ScanTips {
/**
* The items you want to show within the scan tips. See [DocutainListItem] for more details
* on what each item can display. If you don't provide any items, some [defaultItems] will be
* displayed.
*/
items?: DocutainListItem[];
/**
* The toolbar item that will be shown allowing the user to open the scan tips.
*/
toolbarItem?: DocutainButton;
}
/**
* A configuration class used to alter the default document analysis behaviour for payment.
*/
export interface PaymentAnalyzeConfiguration {
/**
* Read BIC.
*
* @default true
*/
readBIC?: boolean;
/**
* Read payment state.
*
* @default false
*/
readPaymentState?: boolean;
/**
* Read SEPA Creditor.
*
* @default true
*/
readSEPACreditor?: boolean;
}
/**
* A configuration class used to alter the default empty result screen.
*/
export interface EmptyResultScreen {
/**
* The items you want to show as scan tips. See [DocutainListItem] for more details
* on what each item can display. If you don't provide any items, some [defaultItems] will be
* displayed.
*/
items?: DocutainListItem[];
/**
* The title to be displayed in the top toolbar.
*/
title?: string;
/**
* The button that restarts the scan process.
*/
repeatButton?: DocutainButton;
}
/**
* A configuration class used to alter the default photo payment behaviour.
*/
export interface PhotoPaymentConfiguration {
/**
* If true, the toolbar will display an Item allowing the user to switch between auto capture and manual capture. Defaults to false.
*
* @default false
*/
allowCaptureModeSetting?: boolean;
/**
* If true, the camera will capture the image automatically at the right moment. Defaults to true.
*
* @default true
*/
autoCapture?: boolean;
/**
* The default scan filter that will be used after scan. Defaults to [ScanFilter.ILLUSTRATION]. See [ScanFilter] for possible values.
*
* @default ScanFilter.ILLUSTRATION
*/
defaultScanFilter?: ScanFilter;
/**
* Configuration class used to alter the default page editing behaviour.
*/
pageEditConfig?: PageEditConfiguration;
/**
* Configuration class used to alter the default color theming behaviour.
*/
colorConfig?: ColorConfig;
/**
* Select the source for the document scanner. Defaults to [Source.CAMERA]. See [Source] for possible values.
*
* @default Source.CAMERA
*/
source?: Source;
/**
* The source images for the document scanner if you have set the [source] to [Source.IMAGE].
*/
sourceImages?: string[];
/**
* If true, image gets automatically cropped if document was detected. This applies only if
* [source] is [Source.IMAGE] or [Source.GALLERY] or [Source.GALLERY_MULTIPLE]. Defaults to true.
*
* @default true
* @since 6.0.0
*/
autoCrop?: boolean;
/**
* If true, scanning multi page documents is possible. Set this to false if you need to scan single page documents. Defaults to true.
*
* @default true
* @since 6.0.0
*/
multiPage?: boolean;
/**
* If true, the camera will run a focus action right before taking the image. This improves the quality
* of the scanned images, but depending on the device, image capture might take a little bit longer.
* Defaults to true.
*
* @default true
* @since 6.0.0
*/
preCaptureFocus?: boolean;
/**
* Configuration class used to alter the default text behaviour.
*
* @default true
* @since 6.0.0
*/
textConfig?: TextConfiguration;
/**
* Configuration class used to alter the default buttons.
*
* @since 6.0.0
*/
buttonConfig?: ButtonConfiguration;
/**
* If true, a list of all pages (thumbnails) will be displayed before the scan process can be finished.
* Defaults to false.
*
* @default false
* @since 6.0.0
*/
confirmPages?: boolean;
/**
* If true, after the scan screen is finished, an editing screen with the captured images will be displayed.
* On the editing screen, the user can crop manually, rotate the page, filter the page and much more.
* The editing screen can be configured by accessing the [pageEditConfig].
* Defaults to true.
*
* @default true
* @since 6.0.0
*/
allowPageEditing?: boolean;
/**
* Overrides the status bar appearance. By default, the system chooses the appearance based on the current UI Mode.
*
* Only available on Android.
*
* @since 6.0.0
*/
statusBarAppearance?: StatusBarAppearance;
/**
* Overrides the navigation bar appearance. By default, the system chooses the appearance based on the current UI Mode.
*
* Only available on Android.
*
* @since 6.0.0
*/
navigationBarAppearance?: NavigationBarAppearance;
/**
* If true, when an image is captured, the device vibrates to signal successful capture.
* Defaults to false.
*/
vibrateOnCapture?: boolean;
/**
* An optional onboarding when the user opens the scanner for the first time. See [Onboarding]
* for more details.
*
* @since 6.0.0
*/
onboarding?: Onboarding | null;
/**
* An optional toolbar item that shows scan tips when clicked. See [ScanTips] for more details.
*
* @since 6.0.0
*/
scanTips?: ScanTips | null;
/**
* Use this to enable/disable additional values to be detected. See [PaymentAnalyzeConfiguration] for
* more details.
*
* @since 6.0.0
*/
analyzeConfig?: PaymentAnalyzeConfiguration;
/**
* A screen that will be displayed if no payment information could be extracted.
* If you do not want to display the screen at all, just set it to null.
*
* @since 6.0.0
*/
emptyResultScreen?: EmptyResultScreen | null;
}