flutter_web_twain

The Flutter plugin is a wrapper for Dynamsoft's Web TWAIN SDK. It allows you to build web document scanning applications with Flutter.

Getting a License Key for Dynamic Web TWAIN

Installation

  1. Add flutter_web_twain as a dependency in your pubspec.yaml file.

  2. In the root of your project, download the Dynamic Web TWAIN npm package:

    npm install dwt
    
  3. Include the following line in your index.html file:

    <script src="node_modules/dwt/dist/dynamsoft.webtwain.min.js"></script>
    

Usage

  • Initialize the Flutter Web TWAIN SDK:

    final FlutterWebTwain _flutterWebTwain = FlutterWebTwain();
    WebTwainController _controller = await _flutterWebTwain.createWebTwainController();
    await _controller!.init('node_modules/dwt/dist/',
           'LICENSE-KEY');
    
  • Embed the image container into your widget tree:

    Expanded(
        child: _controller == null
            ? const CircularProgressIndicator()
            : HtmlElementView(viewType: _controller!.webviewId),
    ),
    
  • Acquire documents from a document scanner:

    await _controller!.scan(
        '{"IfShowUI": false, "PixelType": ${_pixelFormat!.index}}');
    
  • Load images from the local file system:

    await _controller!.load();
    
  • Save single or multiple images as PDF, TIFF or JPEG:

    await _controller!.download(FileFormat.PDF.index, 'filename');
    

Try the Example

cd example
flutter run -d chrome

Flutter web document scanning SDK