As a member of TWAIN Working Group, Dynamsoft is always keeping pace with the latest TWAIN technologies. For the past few years, TWAIN Working Group has been developing a new standard protocol – TWAIN Direct, which aims to expedite the development of applications accessing scanners. With TWAIN Direct, developers do not need to spend time on vendor-specific drivers when building document scanning applications.
In this article, we share a document cloud scan solution based on TWAIN Direct specification and Dynamic Web TWAIN.
Cross-platform Document Scan SDK
Dynamic Web TWAIN is the only JavaScript document scanning SDK that supports Windows, Linux, macOS, and Raspberry Pi. The underlying technology of Dynamic Web TWAIN (DWT) is Dynamsoft Service, which facilitates communication between scanner drivers and JavaScript. Based on the cross-platform nature of Dynamic Web TWAIN, we can conceive a cloud scan solution by combining the TWAIN Direct protocol formatted as a JSON object.
From Local to Cloud
Here is the solution provided by Dynamsoft.
In the workflow above, the Dynamsoft Service is isolated by the DWT Cloud Client. Any commands sent from web browsers will be handled by the TWAIN Cloud Server (web server) first and then forwarded to the DWT Cloud Client via an MQTT server. MQTT is a message management server that is used to send and receive TWAIN-Direct-formatted messages. Once the solution is applied, you can access registered scanners from any web browser on any platform.
The document cloud scan solution is suitable for enterprise in-house usage. For example, if you want to scan a document from your smartphone, you can open a browser and log in to your account to list available scanners in your office, find the closest scanner and conduct the scan operation with your phone.
Document Cloud Scan Solution
Now, we’re going to show you how to set up the testing environment and make the solution work.
Download and Installation
- Dynamic Web TWAIN (Windows, Linux, macOS, and Raspberry Pi)
- Eclipse
- ActiveMQ Artemis
- Visual Studio
Source Code
Get the source code:
git clone https://github.com/dynamsoft-dwt/document-cloud-scan.git
Configuration
License
Get a free trial license from the Dynamsoft website.
Visual Studio (Web server)
Open Server\TwainCloudServer\App_Start\AccountInitializer.cs to create a default account:
var resources = new List<DbUser>
{
new DbUser { name = "dynamsoft", password="1" ,email="support@dynamsoft.com"},
};
Save the account to a database file defined in the web.config file:
<add name="AccountContext" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\dwt.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
ActiveMQ Artemis for Windows
Create a broker via a command-line tool:
artemis create --allow-anonymous localhost
Start the broker by executing:
apache-artemis-2.10.1\bin\localhost\bin\artemis run
If you want to run it in the background, you have to launch cmd.exe as administrator:
apache-artemis-2.10.1\bin\localhost\bin\artemis-service.exe install
apache-artemis-2.10.1\bin\localhost\bin\artemis-service.exe start
To stop the Windows service:
apache-artemis-2.10.1\bin\localhost\bin\artemis-service.exe stop
To uninstall the Windows service:
apache-artemis-2.10.1\bin\localhost\bin\artemis-service.exe uninstall
Eclipse (Client)
Set the product key in JavaClient\src\com\dynamsoft\dwt\Common.java:
public static final String DWT_ProductKey = "LICENSE-KEY";
Deployment
Press F5 to run the web server project in Visual Studio.
Open http://localhost:14032/index.html to see the main page.
Run Artemis:
artemis run
Launch the Java client in Eclipse. You can register scanner information to the cloud server:
In your web browser, click ‘Refresh’ to check the available network scanners. Press the ‘Scan’ button to acquire the document image.
When running the project in Visual Studio, IIS Express is hosting the website. If you want to access the IP address from other machines, add binding information to Server\.vs\config\applicationhost.config. You may also need to enable the 14032 port in Windows Firewall if the IP address is not accessible:
<bindings>
<binding protocol="http" bindingInformation="*:14032:localhost" />
<binding protocol="http" bindingInformation="*:14032:192.168.8.85" />
</bindings>
Restart IIS Express with administrator privileges. You can now scan documents from any platforms, such as macOS:
If the solution is attractive to you, please feel free to try out the source code.
Related Articles
Brand-new Web Document Scanning Methods Based on JSON Data Interchange
Technical Support
If you have any questions about Dynamic Web TWAIN SDK, please contact support@dynamsoft.com.
Release History
V15.2, 09/19/2019
NEW
- [HTML5] Added the capability to add tags to images. The tags can then be used to filter the images. The new APIs are
TagImages
, ClearImageTags
, SetDefaultTag
and FilterImagesByTag
.
IMPROVED
- [HTML5] Tidied up the Dynamsoft Service installer by removing redundant files.
- [HTML5] Unified image decoding capabilities for JPEG and PNG on Windows, macOS, and Linux.
- [HTML5] Improved the speed of PDF decoding by loading the file as a whole instead of per page.
- [HTML5 | Win] Improved Windows buffer management so that its capacity is only limited by the size of disk space on the machine.
- [HTML5 | macOS] Improved macOS installers for better user experience.
- [ActiveX | Win] Aligned PDF rasterizer in ActiveX so that it shares the same feature set with the HTML5 edition.
FIXED
- [HTML5] Fixed a bug with the API CreateTextFont where the text takes up extra space when it is rotated by 90 degrees.
- [HTML5] Fixed a bug where printing results in unnecessary extra blank pages in Firefox or IE11.
- [HTML5] Fixed a bug where a missing filename parameter results in upload failure.
- [HTML5 | Win] Fixed a bug where the library attempts to download an incorrect installer when the Barcode Reader add-on is used.
- [HTML5 | Win] Fixed a bug with the API
GenerateURLForUploadData
so that it returns a URL that shows the correct SDK version. - [All] Fixed a bug where 8-bit image data can't be compressed as a JPEG-TIFF.
- [All]Fixed a bug with the event
OnTopImageInTheViewChanged
where it doesn't get triggered if images are acquired into an empty buffer.