Using the ActiveX plugin to invoke the client scanner to scan files and mountain pass, You can scan the paper files (such as contracts, documents, materials, etc.) and save the scanned images to the server, which can be used for contract management, file management, etc.
By invoking scanner scans and acquiring images via plug-in mode, you can reduce user actions, reduce operation errors, such as large scan volume or continuous scan, which can be used to number scanned files or other processing by the system.
The Web page only needs to start the scanner scan after the JS call, you can get the image encoding of the scanned files, and then the Ajax or form submission to the server decoding after the save as a JPG file.
Through the server program processing, you can easily browse or to other users to share!
Web invoke scanner plugin ActiveX scan image upload and preview
Page HTML code
[HTML]View PlainCopy
- <div id="scanfilelist" style= "height:300px; Overflow:auto; " >
- </div>
- <div>
- < Input type= "checkbox" Id= "Cbo_set" />< label for= "Cbo_set" > display scan settings </label>
- <input < span class= "attribute" >type= "checkbox" id= "Cbo_lxsm" /><label for= "Cbo_lxsm" > continuous scan </label>
- <input type="button" value= "Scan and submit" onclick="Scanclick ();" /> <input type="button" onclick="Selscan ();" value="select Scanner" />
- </div>
Page JS Call ActiveX
[JavaScript]View PlainCopy
- var tscaner = new ActiveXObject ("Tscan.scaner");
[JavaScript]View PlainCopy
- function Selscan () {
- Tscaner.selectscanner ();
- }
- var scanidx=1;
- function Scanclick () {
- Scanidx = 1;
- Scansubmit ();
- }
- function Scansubmit () {
- //tscaner.jpegquality =//jpg image quality
- //tscaner.scanimageleft=10;//location of scanned image (CM)
- //tscaner.scanimagetop=10;//location of scanned image (CM)
- //tscaner.scanimagewidth=20.0;//width of the scanned image cm
- //tscaner.scanimageheight=10.2;//height of the scanned image cm
- if (Tscaner.scan ("#cbo_set"). Is (": Checked") &&scanidx==1) = = 0) {// display the Setup interface only on first scan// Tscaner.scan (TRUE)//Scan settings screen is displayed before scanning
- var imgBase64 = tscaner.scanimagedata;
- if (imgBase64! = "") {
- //Add to list
- $ ("#scanFileList"). Append ("<div id= ' f_" + scanidx + "' style= ' width:80px;height:100px;margin-left:2px ; float:left;border:solid 1px #ccc; ' ></div> ');
- //Upload image
- $.post ("fileup.aspx", {img:imgbase64, id:scanidx}, function (DAT) {
- $ ("#f_" + dat.id + "img"). attr ("src", dat.src);
- }, "JSON");
- }
- //Whether continuous scanning
- if ($ ("#cbo_lxsm"). Is (": Checked")) {
- Scansubmit ();
- }
- }
- }
Server-side (fileup.aspx) receive file code (users can convert to Java, PHP and other languages to adapt to the existing system environment)
[CSharp]View PlainCopy
- String imgBase64 = request.params["img"];
- if (imgBase64! = null && imgBase64! = "")
- {
- byte[] imgbytes = convert.frombase64string (imgBase64);
- string imgpath = "temp/" + System.Guid.NewGuid () + ". jpg";
- System.IO.FileStream fs = new System.IO.FileStream (Server.MapPath (Imgpath), System.IO.FileMode.OpenOrCreate);
- Fs. Write (imgbytes, 0, Imgbytes. Length);
- Fs. Close ();
- Response.Write ("{id:" + request.params["id"] + ", src: '" + Imgpath + "'}");
- }
Online Demo address http://dev.netcoming.com.cn/demos/TScan/Scan.html
Plugin http://download.csdn.net/detail/nxiaoping/5368329
Plug-in authorization 500/domain name (or IP, no limit level two domain name, port, no other restrictions) to assist debugging, testing, improvement
B/S (WEB) system uses the ActiveX plug-in to invoke the scanner for continuous scanning and uploading images (ie files scanned and automatically uploaded)