How to scan documents in JSP

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:

    <script type="text/javascript"> 
        function AcquireImage(){
            var DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
            DWObject.IfShowUI = false;
            DWObject.SelectSource();
            DWObject.OpenSource();
            DWObject.AcquireImage();
        }
    </script>

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.

DWObject.HTTPUploadThroughPostEx(
            strHTTPServer,
            DWObject.CurrentImageIndexInBuffer,
            strActionPage,
            uploadfilename,
            strImageType		
        );

Get Sample Code NOW

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

Subscribe Newsletter

Subscribe to our mailing list to get the monthly update.

Subscribename@email.com