Scan documents from TWAIN scanners in jQuery

As we know, client-side script cannot interact with the imaging devices directly. Here we will use Dynamic Web TWAIN SDK, which is a browser-based document imaging SDK, to interact with scanners, digital cameras and capture images or documents.

Basic features of Dynamic Web TWAIN SDK

  • Compatible with Internet Explorer (32 bit or 64 bit), Edge, Chrome, Firefox, Safari on both Windows and Mac OS X.
  • Support TWAIN scanners, digital cameras & other TWAIN devices
  • Support basic edit operations, including rotate, crop, mirror, flip, erase etc.
  • Save the scanned images to local disk, web server, database, SharePoint document library and more

Learn more about Dynamic Web TWAIN >

Interact with scanner in jQuery

Scan documents from TWAIN scanners using Dynamic Web TWAIN is as easy as below:

 $("#DWTScanButton").click(function () {

        var DWObject = gWebTwain.getInstance(); //render the web twain object

        if (DWObject) {
            if (DWObject.SourceCount > 0) {
                var vDWTSource = document.getElementById("source");
                if (vDWTSource) {

                    if (vDWTSource)
                        DWObject.SelectSourceByIndex(vDWTSource.selectedIndex);
                    else
                        DWObject.SelectSource(); 
                }
                DWObject.CloseSource();
                DWObject.OpenSource();

                DWObject.IfShowUI = document.getElementById("ShowUI").checked;
                var i;
                for (i = 0; i < 3; i++) {
                    if (document.getElementsByName("PixelType").item(i).checked == true)
                        DWObject.PixelType = i;
                }
                DWObject.Resolution = Resolution.value;
                DWObject.IfFeederEnabled = document.getElementById("ADF").checked;
                DWObject.IfDuplexEnabled = document.getElementById("Duplex").checked;

                DWObject.IfDisableSourceAfterAcquire = true;
                DWObject.AcquireImage();
            }
            else
                alert("No TWAIN compatible drivers detected.");
        }
    });

 

The jQuery sample of document scanning can be got from the demo gallery.

You can also download and try the SDK for free.
Get 30-day free trial

Let us know if you have any questions or comments on using  jQuery to interact with scanners.

Subscribe Newsletter

Subscribe to our mailing list to get the monthly update.

Subscribename@email.com