How to Set up Remote Document Scanning on Raspberry Pi

Since version 16.1, Dynamic Web TWAIN (DWT) has added a remote scan feature. If there is a device running a background scanning service (Dynamsoft Service), other devices can access it via an Intranet to use scanners connected to that device, which makes it convenient to use mobile phones to scan documents.

PS: Dynamsoft Service is the core piece of DWT when running in Service mode. It handles the communication between the hardware (scanner, webcam, etc.) and the browser, manages the image buffer, and coordinates data between different modules.1 You can learn more about how DWT and remote scan works in this post.

The recently released Dynamic Web TWAIN v17 has added support for ARM devices. The Dynamsoft Service can now run on ARM devices like Jetson Nano and Raspberry Pi.

Here we will go through how to set up remote document scanning on Raspberry Pi step by step.

What You Should Know About Dynamic Web TWAIN

Set up Remote Scanning on Raspberry Pi

Install Dynamsoft Service

  1. Visit the online demo of DWT: https://demo.dynamsoft.com/web-twain/.
  2. You will be prompted to download and install the Dynamsoft Service.

    download_service_dialog

  3. Install the downloaded deb file with the following line:

     $ sudo dpkg -i DynamsoftServiceSetup-arm64.deb
    
  4. Then, you can scan documents from connected scanners on Raspberry Pi.

Enable Remote Scan on Raspberry Pi

We can visit http://127.0.0.1:18622/ to see if the Dynamsoft Service is running or not. But the service is only accessible in the local network.

We need to config it so that it is accessible in a shared network like a WLAN to enable remote scan.

  1. Open its config file with nano:

     $ nano /opt/dynamsoft/DynamsoftService/DSConfiguration.ini
    
  2. Add this line to the file (you have to change the IP based on your own condition):

     Server=192.168.8.77
    

    The entire config file looks like this:

     [DS]
     CurrentSource=RlVKSVRTVSBmaS03MTYw
     DSVersion=1, 6, 2, 0112
     LogLevel=6
     Port=2
     Port_mn_0=dcp
     Port_mn_1=dwt
     Port_mp_0=18625
     Port_mp_1=18622
     ServiceName=Dynamsoft Service (64-bit)
     Server=192.168.8.77
     SSLPort=2
     SSLPort_mn_0=dcp
     SSLPort_mn_1=dwt
     SSLPort_mp_0=18626
     SSLPort_mp_1=18623
    
  3. Restart the Dynamsoft Service to make the modification effective:

     $ sudo systemctl restart dynamsoft.service
    

    Visit http://<Intranet ip>:18622/ to see if it is accessible.

Scan Documents on Mobile Phones

First, we need to host the web pages on a machine. We can host them on Raspberry Pi or other devices.

  1. Download the remotescan demo: https://github.com/xulihang/mobile-document-scanning/archive/refs/heads/main.zip
  2. Download Dynamic Web TWAIN. Copy its Resources folder with the demo.
  3. Modify the remotescan.html to add the following line to specify the ip of the remote Dynamsoft Service:

     var ip = document.getElementById('remote');
     ip.options.add(new Option("192.168.8.77","192.168.8.77")); //Added line. The ip 192.168.8.77 is for example.
     ip.options.add(new Option(window.location.hostname,window.location.hostname));
    
  4. Run an HTTP server using tools like Python:

     python -m http.server
    

Then, we can take our phone out and visit http://<the web page host's ip>:8000/remotescan.html. We can now use our phone to acquire images from the scanners connected to the Raspberry Pi.

remote scan mobile

PS: If you haven’t enabled remote scan, you may encounter such an error:

service_not_available

References

Search Blog Posts