How to Develop Web-Based Scanning Software for Mac

scanning software for Mac

It’s difficult to control locally-connected peripherals, particularly from a web browser. To facilitate controlling scanners from browsers, the possible options are ActiveX, Applet and browser extensions. However, the time and resources required to code such a solution from scratch is can be severely taxing.

In this post we will show you how to instead use the Dynamic Web TWAIN SDK to easily and quickly create web-based TWAIN scanning software for Mac.

Dynamic Web TWAIN is a TWAIN-based scanning SDK specifically designed for web applications. It provides HTML5 / JS TWAIN libraries. With it, you can easily create scanning software that is compatible with all mainstream browsers on Windows and Mac OS X.

Try an online demo – web scanning on Mac

You can access the online demo to try scanning in your Mac browsers and see how it works.

scan software for Mac demo

Creating scanning software for Mac using Dynamic Web TWAIN

Below are the steps to embed document scanning in your web application using Dynamic Web TWAIN:

  1. First, install Dynamic Web TWAIN. You can download the 30-day free trial here.
  2. Embed Dynamic Web TWAIN in your web page.
    <script type="text/javascript" src="Resources/dynamsoft.webtwain.initiate.js"> </script>
    <script type="text/javascript" src="Resources/dynamsoft.webtwain.config.js"> </script>
    

    Refer to the Developer’s guide for more information on how to embed the scanning SDK in your web page.

  3. Detect scanners, using TWAIN or ImageCaptureCore.
    Dynamic Web TWAIN supports scanning using both TWAIN and native scan on Mac. You can use the ImageCaptureDriverType property to set whether to scan from the TWAIN driver or use the ImageCaptureCore, which comes native with Mac OS X. With the latter, you can scan images from USB-connected scanners and network scanners.
  4. Acquire images from scanners.
    It’s as easy as using the below lines of code to do a scan:

    <input type="button" value="Scan" onclick="AcquireImage();" />
    <script type="text/javascript">
    function AcquireImage(){
    var DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
    DWObject.IfDisableSourceAfterAcquire = true;
    DWObject.SelectSource();
    DWObject.OpenSource();
    DWObject.AcquireImage();
    }
    </script>
    
  5. Save the images as PDF.
    After scanning, you might want to save it as PDF for archiving or sharing. It’s easy to do that as well with Dynamic Web TWAIN. Besides PDF, you can also save as a JPG, TIF, PNG or BMP. Here is the code to save scanned images as a multi-page PDF file.

    //Callback functions for async APIs
    function OnSuccess() {
    console.log('successful');
    }
    function OnFailure(errorCode, errorString) {
    alert(errorString);
    }
    function SaveWithFileDialog() {
    var DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
    if (DWObject) {
    DWObject.IfShowFileDialog = true;
    DWObject.SaveAllAsPDF("DynamicWebTWAIN.pdf", OnSuccess, OnFailure); //save all scanned images as a multi-page pdf file
    }
    }
    

    If you want automatically save as a PDF after scanning, you can use events. How to use events >

  6. Deploy the application to web server.
    To deploy the application on your web server, you just need to copy over the code files along with the Dynamic Web TWAIN libraries.

Conclusion

If you are tasked with creating scanning software for Mac, using a 3rd party scanning SDK like Dynamic Web TWAIN can save you a lot of time and headaches.

Get Free Trial and Samples

To try embedding document scanning in your web application, remember you can download and install a 30-day free trial of Dynamic Web TWAIN.
Get 30-day free trial
You can find more samples from the code gallery.
If you have any questions about creating scanning software for Mac, let us know in the comments section below.

Subscribe Newsletter

Subscribe to our mailing list to get the monthly update.

Subscribename@email.com