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
- Visit the online demo of DWT: https://demo.dynamsoft.com/web-twain/.
You will be prompted to download and install the Dynamsoft Service.
Install the downloaded deb file with the following line:
$ sudo dpkg -i DynamsoftServiceSetup-arm64.deb
- 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.
Open its config file with nano:
$ nano /opt/dynamsoft/DynamsoftService/DSConfiguration.ini
Add this line to the file (you have to change the IP based on your own condition):
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
Restart the Dynamsoft Service to make the modification effective:
$ sudo systemctl restart dynamsoft.service
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.
- Download the remotescan demo: https://github.com/xulihang/mobile-document-scanning/archive/refs/heads/main.zip
- Download Dynamic Web TWAIN. Copy its
Resourcesfolder with the demo.
remotescan.htmlto 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));
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.
PS: If you haven’t enabled remote scan, you may encounter such an error: