flutter_twain_scanner 1.0.1 copy "flutter_twain_scanner: ^1.0.1" to clipboard
flutter_twain_scanner: ^1.0.1 copied to clipboard

A Flutter plugin that enables you to develop desktop, mobile and web applications for digitizing documents from TWAIN, WIA, SANE, ICA and eSCL compatible scanners.

flutter_twain_scanner #

Flutter TWAIN Dynamsoft Service

A Flutter plugin that enables you to develop cross-platform applications for digitizing documents from TWAIN (32-bit/64-bit), WIA, SANE, ICA and eSCL scanners. The plugin offers callable methods for both open-source TWAIN (64-bit only) and the Dynamsoft Service REST API.

Dynamsoft Service REST API #

By default, the REST API's host address is set to http://127.0.0.1:18622.

Method Endpoint Description Parameters Response
GET /DWTAPI/Scanners Get a list of scanners None 200 OK with scanner list
POST /DWTAPI/ScanJobs Creates a scan job license, device, config 201 Created with job ID
GET /DWTAPI/ScanJobs/:id/NextDocument Retrieves a document image id: Job ID 200 OK with image stream
DELETE /DWTAPI/ScanJobs/:id Deletes a scan job id: Job ID 200 OK

To make Dynamsoft Service work:

  1. Install Dynamsoft Service.

  2. Request a free trial license.

Dynamsoft Service Configuration #

After installing the Dynamsoft Service, navigate to http://127.0.0.1:18625/ in a web browser to configure the host and port settings. The default host IP address is set to 127.0.0.1. If you wish to make the service accessible from desktop, mobile, and web applications in your office, you can update the host setting to a LAN IP address, such as 192.168.8.72.

dynamsoft-service-config

API Usage #

Open Source TWAIN (Windows 64-bit only) #

  • Future<List<String>> getDataSources(): Get the list of TWAIN compatible scanners.
    List<String> scanners = await _flutterTwainScannerPlugin.getDataSources();
    
  • Future<List<String>> scanDocument(int sourceIndex): Scan documents from a selected scanner.
    int index = _scanners.indexOf(_selectedScanner!);
    List<String> documentPaths = await _flutterTwainScannerPlugin.scanDocument(index);
    

Dynamsoft Service (Windows, macOS, Linux, Android, iOS and Web) #

  • Future<List<dynamic>> getDevices(String host, [int? scannerType]): Get the list of TWAIN, WIA, and eSCL compatible scanners.

    final DynamsoftService dynamsoftService = DynamsoftService();
    String host = 'http://127.0.0.1:18622';
    final scanners = await dynamsoftService.getDevices(host, ScannerType.TWAINSCANNER | ScannerType.TWAINX64SCANNER);
    
  • Future<void> deleteJob(String host, String jobId): Deletes a scan job based on the provided job ID.

    await dynamsoftService.deleteJob(host, jobId);
    
  • Future<List<String>> getImageFiles(String host, String jobId, String directory): Saves images from a scan job to a directory.

    List<Uint8List> paths =
            await dynamsoftService.getImageFiles(host, jobId, './');
    
  • Future<List<Uint8List>> getImageStreams(String host, String jobId): Retrieves image streams from a scan job.

    List<Uint8List> paths =
            await dynamsoftService.getImageStreams(host, jobId);
    
  • Future<String> scanDocument(String host, Map<String, dynamic> parameters): Creates a new scan job using provided parameters.

    final Map<String, dynamic> parameters = {
      'license':
          'LICENSE-KEY',
      'device': devices[index]['device'],
    };
    
    parameters['config'] = {
      'IfShowUI': false,
      'PixelType': 2,
      'Resolution': 200,
      'IfFeederEnabled': false,
      'IfDuplexEnabled': false,
    };
      
    final String jobId =
          await dynamsoftService.scanDocument(host, parameters);
    

    The scanner parameter configuration is based on Dynamsoft Web TWAIN documentation.

8
likes
150
points
51
downloads

Publisher

verified publisheryushulx.me

Weekly Downloads

A Flutter plugin that enables you to develop desktop, mobile and web applications for digitizing documents from TWAIN, WIA, SANE, ICA and eSCL compatible scanners.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, http, path, plugin_platform_interface

More

Packages that depend on flutter_twain_scanner