b/S (WEB) system using the ActiveX plug-in call scanner for continuous scanning and upload images (ie file scanning and automatic upload)

Source: Internet
Author: User

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
  1. <div id="scanfilelist" style= "height:300px; Overflow:auto; " >
  2. </div>
  3. <div>
  4.         < Input type= "checkbox"   Id= "Cbo_set"  />< label for= "Cbo_set" > display scan settings </label>   
  5.         <input < span class= "attribute" >type= "checkbox"  id= "Cbo_lxsm"  /><label  for= "Cbo_lxsm" > continuous scan </label>  
  6. <input type="button" value= "Scan and submit" onclick="Scanclick ();" /> <input type="button" onclick="Selscan ();" value="select Scanner" />
  7. </div>


Page JS Call ActiveX

[JavaScript]View PlainCopy
    1. var tscaner = new ActiveXObject ("Tscan.scaner");


[JavaScript]View PlainCopy
  1. function Selscan () {
  2. Tscaner.selectscanner ();
  3. }
  4. var scanidx=1;
  5. function Scanclick () {
  6. Scanidx = 1;
  7. Scansubmit ();
  8. }
  9. function Scansubmit () {
  10. //tscaner.jpegquality =//jpg image quality
  11. //tscaner.scanimageleft=10;//location of scanned image (CM)
  12. //tscaner.scanimagetop=10;//location of scanned image (CM)
  13. //tscaner.scanimagewidth=20.0;//width of the scanned image cm
  14. //tscaner.scanimageheight=10.2;//height of the scanned image cm
  15. 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
  16. var imgBase64 = tscaner.scanimagedata;
  17. if (imgBase64! = "") {
  18. //Add to list
  19. $ ("#scanFileList"). Append ("<div id= ' f_" + scanidx + "' style= ' width:80px;height:100px;margin-left:2px ; float:left;border:solid 1px #ccc; '  ></div> ');
  20. //Upload image
  21. $.post ("fileup.aspx", {img:imgbase64, id:scanidx}, function (DAT) {
  22. $ ("#f_" + dat.id + "img"). attr ("src", dat.src);
  23. }, "JSON");
  24. }
  25. //Whether continuous scanning
  26. if ($ ("#cbo_lxsm"). Is (": Checked")) {
  27. Scansubmit ();
  28. }
  29. }
  30. }

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
  1. String imgBase64 = request.params["img"];
  2. if (imgBase64! = null && imgBase64! = "")
  3. {
  4. byte[] imgbytes = convert.frombase64string (imgBase64);
  5. string imgpath = "temp/" + System.Guid.NewGuid () + ". jpg";
  6. System.IO.FileStream fs = new System.IO.FileStream (Server.MapPath (Imgpath), System.IO.FileMode.OpenOrCreate);
  7. Fs. Write (imgbytes, 0, Imgbytes. Length);
  8. Fs. Close ();
  9. Response.Write ("{id:" + request.params["id"] + ", src: '" + Imgpath + "'}");
  10. }

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.