UNPKG

react-native-scanbot-sdk

Version:

Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS

447 lines 15.6 kB
import { NativeModules, Platform } from 'react-native'; import { BarcodeScannerResult } from './barcode'; import { CheckScanningResult } from './check/CheckScannerTypes'; import { ScanbotBarcodeCameraView } from './components/barcode-camera-view/ScanbotBarcodeCameraView'; import { ScanbotDocumentScannerView } from './components/document-scanner-view/ScanbotDocumentScannerView'; import { CreditCardScanningResult } from './credit_card/CreditCardTypes'; import { DocumentDataExtractionResult } from './document_data_extractor'; import { DocumentQualityAnalyzerResult } from './dqa/DocumentQualityAnalyzerTypes'; import { EuropeanHealthInsuranceCardRecognitionResult } from './ehic/EuropeanHealthInsuranceCardTypes'; import { MedicalCertificateScanningResult } from './medical_certificate/MedicalCertificateTypes'; import { MrzScannerResult } from './mrz/MrzTypes'; import { mapRTUUIListResult, mapRTUUIResult } from './utils'; const LINKING_ERROR = `The package 'react-native-scanbot-sdk' doesn't seem to be linked. Make sure: \n\n` + Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; const ScanbotSDKImpl = NativeModules.RNScanbotSDK ? NativeModules.RNScanbotSDK : new Proxy({}, { get() { throw new Error(LINKING_ERROR); } }); const ScanbotSDKUIImpl = NativeModules.RNScanbotRTUUI ? NativeModules.RNScanbotRTUUI : new Proxy({}, { get() { throw new Error(LINKING_ERROR); } }); const ScanbotDocument = { /** * Create a new document. */ createDocument(params) { return ScanbotSDKImpl.createDocument(params); }, /** * Create a new document from legacy pages. */ createDocumentFromLegacyPages(params) { return ScanbotSDKImpl.createDocumentFromLegacyPages(params); }, /** * Create a new document from PDF file. */ createDocumentFromPDF(pdfUri) { return ScanbotSDKImpl.createDocumentFromPDF(pdfUri); }, /** * Check if a document with the given ID exists. */ documentExists(documentID) { return ScanbotSDKImpl.documentExists(documentID); }, /** * Load a document by its ID. */ loadDocument(documentID) { return ScanbotSDKImpl.loadDocument(documentID); }, /** * Gets all stored document IDs. */ storedDocumentIDs() { return ScanbotSDKImpl.storedDocumentIDs(); }, /** * Clone a document by its ID. */ cloneDocument(documentID) { return ScanbotSDKImpl.cloneDocument(documentID); }, /** * Delete a document by its ID. */ deleteDocument(documentID) { return ScanbotSDKImpl.deleteDocument(documentID); }, /** * Delete all documents. */ deleteAllDocuments() { return ScanbotSDKImpl.deleteAllDocuments(); }, /** * Creates a PDF for the given document. * Please check the extra options that are part of the input params to modify the created PDF file per your needs. */ createPDF(params) { return ScanbotSDKImpl.createPDFForDocument(params); }, /** * Creates a TIFF for the given document. * Please check the extra options that are part of the input params to modify the created TIFF file per your needs. */ createTIFF(params) { return ScanbotSDKImpl.createTIFFForDocument(params); }, /** * Add a new page to a document and return the updated document. */ addPage(params) { return ScanbotSDKImpl.addPage(params); }, /** * Move a page in a document and return the updated document. */ movePage(params) { return ScanbotSDKImpl.movePage(params); }, /** * Modify a page in a document and return the updated document. */ modifyPage(params) { return ScanbotSDKImpl.modifyPage(params); }, /** * Remove a page from a document. */ removePage(params) { return ScanbotSDKImpl.removePageFromDocument(params); }, /** * Remove all pages from a document in one batch operation. */ removeAllPages(documentID) { return ScanbotSDKImpl.removeAllPages(documentID); } }; const ScanbotSDKUI = { /** * Opens the Ready-To-Use UI Document Scanner screen with the desired configuration. * * @deprecated Use ***startDocumentScanner*** from ***'react-native-scanbot-sdk/ui_v2'*** instead. */ startDocumentScanner(configuration) { return ScanbotSDKUIImpl.startDocumentScanner(configuration); }, /** * Forces the Ready-To-Use UI Document Scanner screen to close while it is running. * * @deprecated */ closeDocumentScanner() { return ScanbotSDKUIImpl.closeDocumentScanner(); }, /** * Opens the Ready-To-Use UI Finder Document Scanner screen with the desired configuration. * * @deprecated Use ***startDocumentScanner*** from ***'react-native-scanbot-sdk/ui_v2'*** instead. */ startFinderDocumentScanner(configuration) { return ScanbotSDKUIImpl.startFinderDocumentScanner(configuration); }, /** * Forces the Ready-To-Use UI Finder Document Scanner screen to close while it is running. * * @deprecated */ closeFinderDocumentScanner() { return ScanbotSDKUIImpl.closeFinderDocumentScanner(); }, /** * Opens the Ready-To-Use UI Cropping screen with the desired configuration. * * @deprecated Use ***startCroppingScreen*** from ***'react-native-scanbot-sdk/ui_v2'*** instead. */ startCroppingScreen(page, configuration) { return ScanbotSDKUIImpl.startCroppingScreen(page, configuration); }, /** * Forces the Ready-To-Use UI Cropping screen to close while it is running. * * @deprecated */ closeCroppingScreen() { return ScanbotSDKUIImpl.closeCroppingScreen(); }, /** * Opens the Ready-To-Use UI European Health Insurance Card Scanner screen with the desired configuration. * * @deprecated Use ***startDocumentDataExtractor*** instead and enable ***DE_HEALTH_INSURANCE_CARD_FRONT*** and ***EU_HEALTH_INSURANCE_CARD*** document formats. */ async startEHICScanner(configuration) { return ScanbotSDKUIImpl.startEHICScanner(configuration).then(result => mapRTUUIResult(result, EuropeanHealthInsuranceCardRecognitionResult)); }, /** * Forces the Ready-To-Use UI European Health Insurance Card Scanner screen to close while it is running. * * @deprecated */ closeEHICScanner() { return ScanbotSDKUIImpl.closeEHICScanner(); }, /** * Opens the Ready-To-Use UI Medical Certificate Scanner screen with the desired configuration. */ async startMedicalCertificateScanner(configuration) { return ScanbotSDKUIImpl.startMedicalCertificateRecognizer(configuration).then(result => mapRTUUIResult(result, MedicalCertificateScanningResult)); }, /** * Forces the Ready-To-Use UI Medical Certificate Scanner screen to close while it is running. */ closeMedicalCertificateScanner() { return ScanbotSDKUIImpl.closeMedicalCertificateRecognizer(); }, /** * Opens the Ready-To-Use UI Document Data Extractor screen with the desired configuration. */ async startDocumentDataExtractor(configuration) { return ScanbotSDKUIImpl.startDocumentDataExtractor(configuration).then(result => mapRTUUIListResult(result, DocumentDataExtractionResult)); }, /** * Forces the Ready-To-Use UI Document Data Extractor screen to close while it is running. */ closeDocumentDataExtractor() { return ScanbotSDKUIImpl.closeDocumentDataExtractor(); }, /** * Opens the Ready-To-Use UI Check Scanner screen with the desired configuration. */ async startCheckScanner(configuration) { return ScanbotSDKUIImpl.startCheckRecognizer(configuration).then(result => mapRTUUIResult(result, CheckScanningResult)); }, /** * Forces the Ready-To-Use UI Check Scanner screen to close while it is running. */ closeCheckScanner() { return ScanbotSDKUIImpl.closeCheckRecognizer(); }, /** * Opens the Ready-To-Use UI VIN Scanner screen with the desired configuration. */ async startVinScanner(configuration) { return ScanbotSDKUIImpl.startVinScanner(configuration); }, /** * Forces the Ready-To-Use UI VIN Scanner screen to close while it is running. */ closeVinScanner() { return ScanbotSDKUIImpl.closeVinScanner(); } }; const ScanbotSDK = { UI: ScanbotSDKUI, Document: ScanbotDocument, /** * Initializes the Scanbot SDK with the preferred configuration. */ initializeSDK(config) { return ScanbotSDKImpl.initializeSDK(config); }, /** * Provides complete information about the current license status. */ getLicenseInfo() { return ScanbotSDKImpl.getLicenseInfo(); }, /** * Returns the available OCR configs. */ getOCRConfigs() { return ScanbotSDKImpl.getOCRConfigs(); }, /** * Removes all files generated by this plugin. */ cleanup() { return ScanbotSDKImpl.cleanup(); }, /** * Recreates the given pages to refresh the Image URIs. */ refreshImageUris(params) { return ScanbotSDKImpl.refreshImageUris(params); }, /** * Detects barcodes on the image represented by the file URI. The image file URI is part of the input arguments. */ async detectBarcodesOnImage(params) { return ScanbotSDKImpl.detectBarcodesOnImage(params).then(result => new BarcodeScannerResult(result)); }, /** * Applies the given filters to the given image, and returns its URI. */ applyImageFilters(imageFileUri, filters) { return ScanbotSDKImpl.applyImageFilters(imageFileUri, filters); }, /** * Applies the given filters to the given page. */ applyImageFiltersOnPage(page, filters) { return ScanbotSDKImpl.applyImageFiltersOnPage(page, filters); }, /** * Creates a page with the image located at the given URI. */ createPage(imageUri) { return ScanbotSDKImpl.createPage(imageUri); }, /** * Removes the given page from the storage. */ removePage(page) { return ScanbotSDKImpl.removePage(page); }, /** * Rotates the given page for the number of 90 degree counterclockwise rotations. Negative values will rotate clockwise. */ rotatePage(page, times) { return ScanbotSDKImpl.rotatePage(page, times); }, /** * Applies the given image to the desired page. */ setDocumentImage(page, imageUri) { return ScanbotSDKImpl.setDocumentImage(page, imageUri); }, /** * Detects document on the given image and returns the result. */ detectDocument(imageFileUri) { return ScanbotSDKImpl.detectDocument(imageFileUri); }, /** * Detects document on the given page and returns the result. */ detectDocumentOnPage(page) { return ScanbotSDKImpl.detectDocumentOnPage(page); }, /** * Extracts images from a PDF represented by the file URL. The PDF file URL is part of the input arguments. */ extractImagesFromPdf(params) { return ScanbotSDKImpl.extractImagesFromPdf(params); }, /** * Extracts images from a PDF represented by the file URL, creates pages from them and returns the created pages. * The PDF file URL is part of the input arguments. */ extractPagesFromPdf(params) { return ScanbotSDKImpl.extractPagesFromPdf(params); }, /** * Returns the BASE64 Image Data for the given image. */ getImageData(imageFileUri) { return ScanbotSDKImpl.getImageData(imageFileUri); }, /** * Rotates the given image by the specified degrees counterclockwise. Negative values will rotate clockwise. */ rotateImage(imageFileUri, degrees) { return ScanbotSDKImpl.rotateImage(imageFileUri, degrees); }, /** * Detects the quality of the document on a still image. */ async documentQualityAnalyzer(params) { return ScanbotSDKImpl.documentQualityAnalyzer(params).then(result => new DocumentQualityAnalyzerResult(result)); }, /** * Recognizes a Check on the given image. * Set desired check standards or leave it empty/undefined to recognize all supported checks. */ async recognizeCheck(params) { return ScanbotSDKImpl.recognizeCheck(params).then(result => new CheckScanningResult(result)); }, /** * Recognizes an MRZ on the given image. */ async recognizeMrz(params) { return ScanbotSDKImpl.recognizeMrz(params).then(result => new MrzScannerResult(result)); }, /** * Recognizes a Medical Certificate on the given image. * Modify the result with extra options that are part of the input arguments. */ async recognizeMedicalCertificate(params) { return ScanbotSDKImpl.recognizeMedicalCertificate(params).then(result => new MedicalCertificateScanningResult(result)); }, /** * Recognizes a European Health Insurance Card (EHIC) on the given image. * * @deprecated Use ***documentDataExtractor*** instead and enable ***EuropeanHealthInsuranceCardConfiguration*** configuration element. */ async recognizeEHIC(params) { return ScanbotSDKImpl.recognizeEHIC(params).then(result => new EuropeanHealthInsuranceCardRecognitionResult(result)); }, /** * Recognizes a Credit Card on the given image. * Modify the result with extra options that are part of the configuration. */ async recognizeCreditCard(params) { return ScanbotSDKImpl.recognizeCreditCard(params).then(result => new CreditCardScanningResult(result)); }, /** * Extract data on the given image. * Set the expected document formats or leave it empty/undefined to recognize all supported document formats. */ async documentDataExtractor(params) { return ScanbotSDKImpl.documentDataExtractor(params).then(result => new DocumentDataExtractionResult(result)); }, /** * Performs OCR on given images. Set preferred ***ocrConfiguration*** engine, or leave it undefined to use the default one which is ***OCRScanbotEngineConfiguration***. * If ***OCRTesseractConfiguration*** is used, the expected ***languages*** need to be set. */ performOCR(params) { return ScanbotSDKImpl.performOCR(params); }, /** * Creates a PDF using the given list of image file URIs. * Please check the extra options that are part of the input arguments to modify the created PDF file per your needs. */ createPDF(params) { return ScanbotSDKImpl.createPDF(params); }, /** * Creates a TIFF using the given list of image file URIs. * Please check the extra options that are part of the input arguments to modify the created TIFF file per your needs. */ writeTIFF(params) { return ScanbotSDKImpl.writeTIFF(params); } }; export default ScanbotSDK; export * from './barcode'; export * from './base'; export * from './check/CheckScannerTypes'; export * from './credit_card/CreditCardTypes'; export * from './document_data_extractor'; export * from './document_scanner'; export * from './documents'; export * from './dqa/DocumentQualityAnalyzerTypes'; export * from './ehic/EuropeanHealthInsuranceCardTypes'; export * from './frame_accumulation/FrameAccumulationTypes'; export * from './imageRef'; export * from './image_filters/ParametricFilters'; export * from './medical_certificate/MedicalCertificateTypes'; export * from './mrz/MrzTypes'; export * from './ocr_renderer/PdfConfigurationTypes'; export * from './text_pattern_scanner/TextPatternScannerTypes'; export * from './tiff_wrapper/TiffTypes'; export * from './utils'; export * from './vin/VinScannerTypes'; export * from './components/CameraViewTypes'; export * from './components/barcode-camera-view/ScanbotBarcodeCameraViewProperties'; export * from './components/document-scanner-view/ScanbotDocumentScannerViewProperties'; export { ScanbotBarcodeCameraView, ScanbotDocumentScannerView }; //# sourceMappingURL=index.js.map