UNPKG

capacitor-plugin-scanbot-sdk

Version:

Scanbot Document and Barcode Scanner SDK for Capacitor

495 lines 18.4 kB
import { registerPlugin } from '@capacitor/core'; import { AnalyticsEvent } from './analytics/Analytics'; import { BarcodeScannerResult } from './barcode/BarcodeScannerTypes'; import { CheckScanningResult } from './check/CheckScannerTypes'; import { CreditCardScanningResult } from './credit_card/CreditCardTypes'; import { DocumentDataExtractionResult, DocumentVerificationReport, } from './document_data_extractor/DocumentDataExtractorTypes'; import { DocumentData } from './document_scanner/DocumentData'; import { DocumentQualityAnalyzerResult } from './dqa/DocumentQualityAnalyzerTypes'; import { EuropeanHealthInsuranceCardRecognitionResult, } from './ehic/EuropeanHealthInsuranceCardTypes'; import { MedicalCertificateScanningResult } from './medical_certificate/MedicalCertificateTypes'; import { MrzScannerResult } from './mrz/MrzTypes'; import { mapRTUUIResult } from './utils/utils'; import { VinScannerResult } from './vin/VinScannerTypes'; const _registeredPlugin = registerPlugin('ScanbotSDKCapacitor', {}); /** @internal */ export const _ScanbotSDKInternalUiV2 = _registeredPlugin; /** @internal */ export const ScanbotSDKInternal = _registeredPlugin; const ScanbotDocument = { /** * Create a new document. */ createDocument(params) { return ScanbotSDKInternal.createDocument(params).then((result) => new DocumentData(result)); }, /** * Create a new document from legacy pages. */ createDocumentFromLegacyPages(params) { return ScanbotSDKInternal.createDocumentFromLegacyPages(params).then((result) => new DocumentData(result)); }, /** * Create a new document from a PDF file. */ createDocumentFromPDF(params) { return ScanbotSDKInternal.createDocumentFromPDF(params).then((result) => new DocumentData(result)); }, /** * Check if a document with the given ID exists. */ documentExists(params) { return ScanbotSDKInternal.documentExists(params); }, /** * Load a document by its ID. */ loadDocument(params) { return ScanbotSDKInternal.loadDocument(params).then((result) => new DocumentData(result)); }, /** * Gets all stored document IDs. */ storedDocumentIDs() { return ScanbotSDKInternal.storedDocumentIDs(); }, /** * Clone a document by its ID. */ cloneDocument(params) { return ScanbotSDKInternal.cloneDocument(params).then((result) => new DocumentData(result)); }, /** * Delete a document by its ID. */ deleteDocument(params) { return ScanbotSDKInternal.deleteDocument(params); }, /** * Delete all documents. */ deleteAllDocuments() { return ScanbotSDKInternal.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 ScanbotSDKInternal.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 ScanbotSDKInternal.createTIFF(params); }, /** * Add a new page to a document and return the updated document. */ addPage(params) { return ScanbotSDKInternal.addPage(params).then((result) => new DocumentData(result)); }, /** * Move a page in a document and return the updated document. */ movePage(params) { return ScanbotSDKInternal.movePage(params).then((result) => new DocumentData(result)); }, /** * Modify a page in a document and return the updated document. */ modifyPage(params) { return ScanbotSDKInternal.modifyPage(params).then((result) => new DocumentData(result)); }, /** * Remove a page from a document. */ removePage(params) { return ScanbotSDKInternal.removePageFromDocument(params).then((result) => new DocumentData(result)); }, /** * Remove all pages from a document in one batch operation. */ removeAllPages(params) { return ScanbotSDKInternal.removeAllPages(params).then((result) => new DocumentData(result)); }, }; export const ScanbotSDK = { Document: ScanbotDocument, /** * Opens the Ready-To-Use UI Document Scanner screen with the desired configuration. * * @deprecated Use ***startDocumentScanner*** from ***'capacitor-plugin-scanbot-sdk/ui_v2'*** instead. */ startDocumentScanner(configuration) { return ScanbotSDKInternal.startDocumentScanner(configuration); }, /** * Forces the Ready-To-Use UI Document Scanner screen to close while it is running. * * @deprecated */ closeDocumentScanner() { return ScanbotSDKInternal.closeDocumentScanner(); }, /** * Opens the Ready-To-Use UI Finder Document Scanner screen with the desired configuration. * * @deprecated Use ***startDocumentScanner*** from ***'capacitor-plugin-scanbot-sdk/ui_v2'*** instead. */ startFinderDocumentScanner(configuration) { return ScanbotSDKInternal.startFinderDocumentScanner(configuration); }, /** * Forces the Ready-To-Use UI Finder Document Scanner screen to close while it is running. * * @deprecated */ closeFinderDocumentScanner() { return ScanbotSDKInternal.closeFinderDocumentScanner(); }, /** * Opens the Ready-To-Use UI Cropping screen with the desired configuration. * * @deprecated Use ***startCroppingScreen*** from ***'capacitor-plugin-scanbot-sdk/ui_v2'*** instead. */ startCroppingScreen(params) { return ScanbotSDKInternal.startCroppingScreen(params); }, /** * Forces the Ready-To-Use UI Cropping screen to close while it is running. * * @deprecated */ closeCroppingScreen() { return ScanbotSDKInternal.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 ScanbotSDKInternal.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 ScanbotSDKInternal.closeEHICScanner(); }, /** * Opens the Ready-To-Use UI Medical Certificate Scanner screen with the desired configuration. */ async startMedicalCertificateScanner(configuration) { return ScanbotSDKInternal.startMedicalCertificateScanner(configuration).then((result) => mapRTUUIResult(result, MedicalCertificateScanningResult)); }, /** * Forces the Ready-To-Use UI Medical Certificate Scanner screen to close while it is running. */ closeMedicalCertificateScanner() { return ScanbotSDKInternal.closeMedicalCertificateScanner(); }, /** * Opens the Ready-To-Use UI Check Scanner screen with the desired configuration. * * @deprecated Use ***startCheckScanner*** from ***'capacitor-plugin-scanbot-sdk/ui_v2'*** instead. */ async startCheckScanner(configuration) { return ScanbotSDKInternal.startCheckScanner(configuration).then((result) => mapRTUUIResult(result, CheckScanningResult)); }, /** * Forces the Ready-To-Use UI Check Scanner screen to close while it is running. * * @deprecated */ closeCheckScanner() { return ScanbotSDKInternal.closeCheckScanner(); }, /** * Opens the Ready-To-Use UI VIN Scanner screen with the desired configuration. * * @deprecated Use ***startVINScanner*** from ***'capacitor-plugin-scanbot-sdk/ui_v2'*** instead. */ startVinScanner(configuration) { return ScanbotSDKInternal.startVinScanner(configuration).then((result) => mapRTUUIResult(result, VinScannerResult)); }, /** * Forces the Ready-To-Use UI VIN Scanner screen to close while it is running. * * @deprecated */ closeVinScanner() { return ScanbotSDKInternal.closeVinScanner(); }, /** * Initializes the Scanbot SDK with the preferred configuration. */ initializeSDK(config) { return ScanbotSDKInternal.initializeSDK(config); }, /** * Provides complete information about the current license status. */ getLicenseInfo() { return ScanbotSDKInternal.getLicenseInfo(); }, /** * Detects barcodes on the image represented by the file URI. */ async detectBarcodesOnImage(imageFileUri, configuration) { return ScanbotSDKInternal.detectBarcodesOnImage({ imageFileUri: imageFileUri, configuration: configuration, }).then((result) => new BarcodeScannerResult(result)); }, /** * Applies the given filters to the given image, and returns its URI. */ applyImageFilters(params) { return ScanbotSDKInternal.applyImageFilters(params); }, /** * Applies the given filters to the given page. * * @deprecated Use {@link ScanbotSDK.Document.modifyPage} instead. */ applyImageFiltersOnPage(params) { return ScanbotSDKInternal.applyImageFiltersOnPage(params); }, /** * Returns the BASE64 Image Data for the given image. */ getImageData(params) { return ScanbotSDKInternal.getImageData(params); }, /** * Rotates the given image by the specified degrees. */ rotateImage(params) { return ScanbotSDKInternal.rotateImage(params); }, /** * Creates a page with the image located at the given URI. * * @deprecated Use {@link ScanbotSDK.Document.createDocument} instead. */ createPage(params) { return ScanbotSDKInternal.createPage(params); }, /** * Removes the given page from the storage. * * @deprecated Use {@link ScanbotSDK.Document.removePage} instead. */ removePage(params) { return ScanbotSDKInternal.removePage(params); }, /** * Rotates the given page for the number of 90 degree counterclockwise rotations. Negative values will rotate clockwise. * * @deprecated Use {@link ScanbotSDK.Document.modifyPage} instead. */ rotatePage(params) { return ScanbotSDKInternal.rotatePage(params); }, /** * Applies the given image to the desired page. * * @deprecated Use {@link ScanbotSDK.Document} instead. */ setDocumentImage(params) { return ScanbotSDKInternal.setDocumentImage(params); }, /** * Detects a document on the given image and returns the result. */ detectDocument(params) { return ScanbotSDKInternal.detectDocument(params); }, /** * Detects a document on the given page and returns the result. * * @deprecated Use {@link ScanbotSDK.Document} instead. */ detectDocumentOnPage(params) { return ScanbotSDKInternal.detectDocumentOnPage(params); }, /** * Detects the quality of the document on a still image. */ async documentQualityAnalyzer(imageFileUri, configuration) { return ScanbotSDKInternal.documentQualityAnalyzer({ imageFileUri: imageFileUri, configuration: configuration, }).then((result) => new DocumentQualityAnalyzerResult(result)); }, /** * Extracts images from a PDF represented by the file URL. The PDF file URL is part of the input params. */ extractImagesFromPdf(params) { return ScanbotSDKInternal.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 params. * * @deprecated Use {@link ScanbotSDK.Document.createDocumentFromPDF} instead. */ extractPagesFromPdf(params) { return ScanbotSDKInternal.extractPagesFromPdf(params); }, /** * Recognizes a check in the given image using the preferred configuration. */ async recognizeCheck(imageFileUri, configuration) { return ScanbotSDKInternal.recognizeCheck({ imageFileUri: imageFileUri, configuration: configuration, }).then((result) => new CheckScanningResult(result)); }, /** * Recognizes an MRZ on the given image. */ async recognizeMrz(imageFileUri, configuration) { return ScanbotSDKInternal.recognizeMrz({ imageFileUri: imageFileUri, configuration: configuration, }).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 params. */ async recognizeMedicalCertificate(imageFileUri, configuration) { return ScanbotSDKInternal.recognizeMedicalCertificate({ imageFileUri: imageFileUri, configuration: configuration, }).then((result) => new MedicalCertificateScanningResult(result)); }, /** * Recognizes a European Health Insurance Card (EHIC) on the given image. * * @deprecated Use {@link documentDataExtractor} instead and enable ***EuropeanHealthInsuranceCardConfiguration*** configuration element. */ async recognizeEHIC(imageFileUri, configuration) { return ScanbotSDKInternal.recognizeEHIC({ imageFileUri: imageFileUri, configuration: configuration, }).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(imageFileUri, configuration) { return ScanbotSDKInternal.recognizeCreditCard({ imageFileUri: imageFileUri, configuration: configuration, }).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(imageFileUri, configuration) { return ScanbotSDKInternal.documentDataExtractor({ imageFileUri: imageFileUri, configuration: configuration, }).then((result) => new DocumentDataExtractionResult(result)); }, /** * Recreates the given pages to refresh the Image URIs. * * @deprecated Use {@link ScanbotSDK.Document} instead. */ refreshImageUris(params) { return ScanbotSDKInternal.refreshImageUris(params); }, /** * Returns the available OCR configs. */ getOCRConfigs() { return ScanbotSDKInternal.getOCRConfigs(); }, /** * Removes all files generated by this plugin. */ cleanup() { return ScanbotSDKInternal.cleanup(); }, /** * 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 ScanbotSDKInternal.performOCR(params); }, /** * Creates a PDF using the given list of image file URIs. * Please check the extra options that are part of the input params to modify the created PDF file per your needs. */ createPDF(params) { return ScanbotSDKInternal.createPDF(params); }, /** * Creates a TIFF using the given list of image file URIs. * Please check the extra options that are part of the input params to modify the created TIFF file per your needs. */ writeTIFF(params) { return ScanbotSDKInternal.writeTIFF(params); }, /** * Verifies the given document parts using the DocumentDataExtractorConfiguration. */ async verifyDocument(documentParts, configuration) { return ScanbotSDKInternal.verifyDocument({ documentParts, configuration }).then((result) => new DocumentVerificationReport(result)); }, /** * Register analytics service callback to receive analytics events. */ setAnalyticsSubscriber(subscriber) { if (subscriber === null) { return ScanbotSDKInternal.removeAnalyticsServiceCallback(); } else { return ScanbotSDKInternal.setAnalyticsServiceCallback({}, (event) => { if (event) { subscriber(new AnalyticsEvent(event)); } }); } }, /** * Mock camera preview by using static images as a frame source. * This is useful for testing purposes. */ mockCamera(params) { return ScanbotSDKInternal.mockCamera(params); }, }; export * from './analytics/index'; export * from './barcode/index'; export * from './base/index'; export * from './check/CheckScannerTypes'; export * from './credit_card/CreditCardTypes'; export * from './document_data_extractor/index'; export * from './document_scanner/index'; export * from './documents/index'; export * from './dqa/DocumentQualityAnalyzerTypes'; export * from './ehic/EuropeanHealthInsuranceCardTypes'; export * from './frame_accumulation/FrameAccumulationTypes'; export * from './image_filters/ParametricFilters'; export * from './imageRef/index'; 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/index'; export * from './vin/VinScannerTypes'; //# sourceMappingURL=index.js.map