diff --git a/Libraries.txt b/Libraries.txt index e8ed22a..37bb875 100644 --- a/Libraries.txt +++ b/Libraries.txt @@ -1,4 +1,4 @@ -Open Source libraries used in the Scanbot SDK Flutter Plugin version 4.2.2: +Open Source libraries used in the Scanbot SDK Flutter Plugin version 4.2.3: //------------------------------------------------------------- collection 1.17.1 diff --git a/lib/ui/classical_components/cropping_custom_ui.dart b/lib/ui/classical_components/cropping_custom_ui.dart index c5ec1e6..8bf1832 100644 --- a/lib/ui/classical_components/cropping_custom_ui.dart +++ b/lib/ui/classical_components/cropping_custom_ui.dart @@ -25,7 +25,7 @@ class _CroppingScreenWidgetState extends State { CroppingController? croppingController; - _CroppingScreenWidgetState(this.currentPage) {} + _CroppingScreenWidgetState(this.currentPage); @override void initState() { diff --git a/lib/ui/preview_document_widget.dart b/lib/ui/preview_document_widget.dart index c372204..8f94320 100644 --- a/lib/ui/preview_document_widget.dart +++ b/lib/ui/preview_document_widget.dart @@ -167,7 +167,7 @@ class _DocumentPreviewState extends State { title: const Text('Save as PDF'), onTap: () { Navigator.pop(context); - _createPdf(); + _createPDF(); }, ), ListTile( @@ -175,7 +175,7 @@ class _DocumentPreviewState extends State { title: const Text('Save as PDF with OCR'), onTap: () { Navigator.pop(context); - _createOcrPdf(); + _createPdfWithOCR(); }, ), ListTile( @@ -330,34 +330,9 @@ class _DocumentPreviewState extends State { } } - Future _createPdf() async { - if (!await _checkHasPages(context)) { - return; - } - if (!await checkLicenseStatus(context)) { - return; - } - - final dialog = ProgressDialog(context, - type: ProgressDialogType.Normal, isDismissible: false); - dialog.style(message: 'Creating PDF ...'); - try { - dialog.show(); - var options = const PdfRenderingOptions(pageSize: PageSize.A4); - final pdfFileUri = - await ScanbotSdk.createPdf(_pageRepository.pages, options); - await dialog.hide(); - await showAlertDialog(context, pdfFileUri.toString(), - title: 'PDF file URI'); - } catch (e) { - print(e); - await dialog.hide(); - } - } - Future _importImage() async { try { - final image = await ImagePicker().getImage(source: ImageSource.gallery); + final image = await ImagePicker().pickImage(source: ImageSource.gallery); await _createPage(Uri.file(image?.path ?? '')); } catch (e) { print(e); @@ -429,7 +404,7 @@ class _DocumentPreviewState extends State { dialog.show(); try { final result = await ScanbotSdk.performOcr(_pages, - OcrOptions(languages: ['en', 'de'], shouldGeneratePdf: false)); + OcrOptions(languages: ['en', 'de'])); await dialog.hide(); await showAlertDialog( context, 'Plain text:\n' + (result.plainText ?? '')); @@ -439,7 +414,32 @@ class _DocumentPreviewState extends State { } } - Future _createOcrPdf() async { + Future _createPdfWithOCR() async { + if (!await _checkHasPages(context)) { + return; + } + if (!await checkLicenseStatus(context)) { + return; + } + + final dialog = ProgressDialog(context, + type: ProgressDialogType.Normal, isDismissible: false); + dialog.style(message: 'Creating PDF with OCR ...'); + try { + dialog.show(); + var options = const PdfRenderingOptions(pageSize: PageSize.A4); + final pdfFileUri = + await ScanbotSdk.createPdf(_pageRepository.pages, options, shouldGeneratePdfWithOcr: true); + await dialog.hide(); + await showAlertDialog(context, pdfFileUri.toString(), + title: 'PDF with OCR file URI'); + } catch (e) { + print(e); + await dialog.hide(); + } + } + + Future _createPDF() async { if (!await _checkHasPages(context)) { return; } @@ -449,18 +449,14 @@ class _DocumentPreviewState extends State { var dialog = ProgressDialog(context, type: ProgressDialogType.Normal, isDismissible: false); - dialog.style(message: 'Performing OCR with PDF ...'); - dialog.show(); + dialog.style(message: 'Creating PDF ...'); try { - var result = await ScanbotSdk.performOcr( - _pages, OcrOptions(languages: ['en', 'de'], shouldGeneratePdf: true)); + dialog.show(); + var options = const PdfRenderingOptions(pageSize: PageSize.A4); + var result = await ScanbotSdk.createPdf(_pageRepository.pages, options, shouldGeneratePdfWithOcr: false); await dialog.hide(); - await showAlertDialog( - context, - 'PDF File URI:\n' + - (result.pdfFileUri ?? '') + - '\n\nPlain text:\n' + - (result.plainText ?? '')); + await showAlertDialog(context, result.toString(), + title: 'PDF File URI'); } catch (e) { print(e); await dialog.hide(); diff --git a/pubspec.lock b/pubspec.lock index 96fe55b..cab1b47 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -355,10 +355,9 @@ packages: scanbot_sdk: dependency: "direct main" description: - name: scanbot_sdk - sha256: "473366a4e8e0275d4a5c1950f954e872c62099dd5c66e7ff9d3385b3fde46dda" - url: "https://pub.dev" - source: hosted + path: "../scanbot-sdk-flutter" + relative: true + source: path version: "4.2.2" shared_preferences: dependency: "direct main" diff --git a/pubspec.yaml b/pubspec.yaml index 1bad1c7..ef6acab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -22,7 +22,8 @@ dependencies: flutter: sdk: flutter - scanbot_sdk: ^4.2.2 + scanbot_sdk: + path: ../scanbot-sdk-flutter/ cupertino_icons: ^1.0.2