function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Leafen SandyLeafen Sandy 

Is there a way to scan a document directly using a vf page or a button script?

I want to scan document without installing any desktop applications or salesforce packages, and to save that directly scanned document as an attachment in an object.
Is there a way to do this?
karthikeyan perumalkarthikeyan perumal
Hello, 

Use below code for scan using VF page.   before that you need to enable Java TM Plugin for browser level-option 1 or try to install that app in option 2.
 
<apex:page >
 <html><head>
  <script src="https://asprise.azureedge.net/scannerjs/scanner.js" type="text/javascript"></script>
  <script type="text/javascript">
    var scanRequest = {
      "use_asprise_dialog": true, // Whether to use Asprise Scanning Dialog
      "show_scanner_ui": false, // Whether scanner UI should be shown
      "twain_cap_setting": { // Optional scanning settings
        "ICAP_PIXELTYPE": "TWPT_RGB" // Color
      },
      "output_settings": [{
        "type": "return-base64", "format": "jpg"
      }]
   };

   function scan() { // Triggers the scan
    scanner.scan(displayImagesOnPage, scanRequest);
   }

   function displayImagesOnPage(successful, mesg, response) { // Handler
    var scannedImages = scanner.getScannedImages(response, true, false); // returns an array of ScannedImage
    for (var i = 0; (scannedImages instanceof Array) && i < scannedImages.length; i++) {
        var scannedImage = scannedImages[i];
        var elementImg = scanner.createDomElementFromModel({ 'name': 'img', 'attributes': { 'class': 'scanned', 'src': scannedImage.src  } });
        (document.getElementById('images') ? document.getElementById('images') : document.body).appendChild(elementImg);
    }
  }
  </script></head><body>
  <button type="button" onclick="scan();">Scan</button> <div id="images"/>
</body></html>
</apex:page>

Hope this will help you. 

Thanks
karthik
 
Leafen SandyLeafen Sandy
Hi Karthik,

Thanks, 

I have a hurdle even in this approach.

Plugins that use NPAPI, including Silverlight, Java, and Unity has ended due to security issues.
(https://java.com/en/download/faq/chrome.xml)

So Chrome will no longer support Java Plugin(Same is the case with Mozilla Firefox as well).
So is there is any other way, without going for the option 2(Installing the "ScanApp").

Regards,
Leaf.