How to scan documents in JSP

Last Updated on 2018-10-08

If you are developing a web application in JSP and want to integrate document scanner, e.g. add a scan button which on clicking will invoke the scanning process from a scanner connected to the client machine, you can use a web-based TWAIN SDK like Dynamic Web TWAIN.

Dynamic Web TWAIN is a client-side TWAIN SDK which enables you to interact with TWAIN devices (scanners, cameras etc.) in JavaScript. Using the SDK, you can embed scan to your JSP page with just a couple of lines of code.

Scan Documents in JSP

System Requirements:

  • Compatible with Internet Explorer v6 and above, both 32 and 64 bit.
  • Compatible with Chrome and Firefox on Windows with HTML5/JavaScript library and NPAPI plugin.
  • Compatible with Safari on Mac OS X.

Code Snippet:

You can basically achieve scanning in minutes with the following JS code:
[javascript] <script type="text/javascript">
function AcquireImage(){
var DWObject = Dynamsoft.WebTwainEnv.GetWebTwain(‘dwtcontrolContainer’);
DWObject.IfShowUI = false;
DWObject.SelectSource();
DWObject.OpenSource();
DWObject.AcquireImage();
}
</script>
[/javascript]
Dynamic Web TWAIN also provides HTTP upload methods which enables you to save the scanned documents to local / server disk, database, document library as images (JPEG, PDF, TIFF, PNG, BMP), base64 and byte arrays for further processing or storing.
[javascript]DWObject.HTTPUploadThroughPostEx(
strHTTPServer,
DWObject.CurrentImageIndexInBuffer,
strActionPage,
uploadfilename,
strImageType
);[/javascript]
Get Sample Code NOW

Let us know if you have any questions or comments on developing a JSP application to interact with scanners.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe Newsletter

Subscribe to our mailing list to get the monthly update.

Subscribename@email.com