Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Dears ,

I want to knew how can i add the scanning functionality to my MVC website
Scenario : user will click the scanning button web site will call scanning device and a pop up will be opened to preview the scanned document then user can confirm then file will be uploaded to the server ?

my question is : is there any pure/free .net library interact with scanners or supporting me to code this functionality ?

or any suggestion ?

Note : i googled for it and all result related to some libraries (not free) ?

Thanks
Posted
Comments
F-ES Sitecore 28-Jan-16 6:21am    
Your webserver can't interact with client hardware. Any library you use will need to work on the client, be able to access client hardware, and be able to transmit the data as a stream to your website, so the client will need to be some kind of installable component or browser plug-in as javascript alone can't do these things (although they are developing these kinds of features into html5, but I don't think they are usable yet). All of the scanner libraries you find will assume the scanner is physically attached to the machine the code is running on so that rules them out.

There is a reason websites that need scanned documents simply ask you to scan the document yourself and then just upload the file.
Yasser El Shazly 28-Jan-16 6:37am    
yes but it is a must to apply this functionality to my website , and i have no problem to have all rights and permissions to use client resources ... but how?
and i have no problems with scanning files on local machine in a specific folder and some how upload the file automatically ... thanks.
F-ES Sitecore 28-Jan-16 6:41am    
You can't upload files automatically either. Unless you find a component that does what you want, you'll probably need to revert to a manual process. The web is simply not designed for the task you are doing, there are a million security issues standing in your way.
Yasser El Shazly 28-Jan-16 6:58am    
Okay i get your point , put i am thinking to scanning in an specific folder like C:\\Scanning --- then scan in this folder and read all files by JavaScript in this folder , but the point how can i scan using .Net ?
F-ES Sitecore 28-Jan-16 7:00am    
You can't do that, you can't access the client system from your .net code. Can you imagine the security implications if websites could scan your drive and access files?

You cannot do this with server-side code (MVC code in your case).

You CAN however do this by requiring the client-side to install a program. This program would do two jobs in a Windows Service app. This first part is the piece that interfaces with the scanner and scans the documents.

The second part would be a web server that the javascript code in your client pages can get to. Any commands that you need to send to the web server can be used to control when and how a document is scanned. The scanner side of the service can be controlled from the web server wide. Once a document is scanned, the resulting image file can be served up by the webserver side and back to the javascript code in your web page. Once there, it can then upload the file to your web server (MVC).
 
Share this answer
 
I hope it's about scanning on the client side. Sorry for not giving you a real solution; this is a difficult problem, mostly because of transitional state of affairs in Web standardization; I would say, we are not there yet.

I hoped we can be covered by the W3 standard HTML Media Capture (at this moment, candidate recommendations of September 2014): HTML Media Capture[^].

Well, not so fast. Even though the major browsers often implement HTML5 features well before the official standard is accepted, don't hold your breath. I've found a good overview of the problem in this Stackoverflow answer: Can HTML5 communicate with peripherals like scanners and credit card readers? — Stack Overflow[^].

Another article explains the approach based on WebRTC: https://hacks.mozilla.org/2013/02/cross-browser-camera-capture-with-getusermediawebrtc[^];
see also: WebRTC — Wikipedia, the free encyclopedia[^],
WebRTC Home | WebRTC[^].

From the other hand, long time ago, I faced Web sites performing scanning on the client site just by using the scanner installed on the client system. How was it possible? My guess is: in some dirty way. Oh yes, there are dirty ways, such as ActiveX used in a browser (so it may work only on limited set of platforms and browsers), but this is something I don't even want to discuss. I denied to scan my sensitive documents through the service offered, because such things are considered utterly unsafe, for some very good reasons, so your security-savvy customer will also deny using such possibility or may even blacklist your site if they find out that you are using such dirty tricks. Perhaps less dangerous approach would be having some browser plug-in which could be installed on the explicit customer's permission, but 1) it can be only specific to a certain browser and platform; 2) it's not too much different from letting the user to scan documents if a file and uploading the file.

Conclusions?

Sure. If you really need to support scanning, I think at this moment the best option would be to leave this job to the user. A person who has a scanner connected to her/his computer or LAN usually knows how to use it. And it has a lot of benefits over scanning from a browser. First of all, the user has more control. This person can scan document today and send it tomorrow. The file created is not a hassle, it's a good feature; it can be saved for user's records, and so on. Finally, the file can be properly converted and processed to the user's liking (cropped, rotated, normalized…). But what I consider as a benefit some may consider as a problem. Let's discuss that…

Some think that forcing the customer to scan a document in a browser would prevent document forging, would ensure authentic copy of a paper. I am not saying that you are one of people thinking this way, so please don't get offended by what I want to say next: this is one of the most naive delusions. In fact, most people won't even try to forge anything, even if they have an image file to upload. But those who want to create a fake document could forge it in no time even if you force in-browser scanning. And this is fairly easy. For example, a simulation scanner driver can be created; it would "scan" not physically, but would feed existing (forged or not) picture.

So, I gave you strong arguments to throw out the idea of in-browser scanning and just let people to upload images.

—SA
 
Share this answer
 
v9

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900