700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > B/S(WEB)系统中使用websocket插件调用扫描仪实现连续扫描并上传图像(IE文件扫描并自动上传)

B/S(WEB)系统中使用websocket插件调用扫描仪实现连续扫描并上传图像(IE文件扫描并自动上传)

时间:2024-07-24 08:30:46

相关推荐

B/S(WEB)系统中使用websocket插件调用扫描仪实现连续扫描并上传图像(IE文件扫描并自动上传)

浏览器下使用websocket插件调用客户端扫描仪扫描文件并山传,可以将纸质档案(如合同、文件、资料等)扫描并将扫描图像保存到服务器,可以用于合同管理、档案管理等。

通过插件方式调用扫描仪扫描并获取图像,可以减少用户操作,减少操作出错,如一次扫描量大也可以使用连续扫描,由系统对扫描文件进行编号或进行其他处理。

web页面中只需通过js调用后启动扫描仪扫描,即可获取扫描文件的图像编码,再通过ajax或表单提交到服务器解码后保存为jpg文件即可。

通过服务器上程序处理后,可以方便以后浏览或去其它用户共享!

web调用扫描仪插件activex扫描图像上传并预览

页面HTML代码

<div id="scanFileList" style="height:300px; overflow:auto;"></div><div><input type="checkbox" id="cbo_set" /><label for="cbo_set">显示扫描设置</label><input type="checkbox" id="cbo_lxsm" /><label for="cbo_lxsm">连续扫描</label><input type="button" value="扫描并提交" onclick="scanClick();" /> <input type="button" onclick="selscan();" value="选择扫描仪" /></div>

页面js调用websocket连接控件服务调用扫描仪

function selscan() {tScaner.SelectScanner();}var scanidx=1;function scanClick() {scanidx = 1;scanSubmit();}function scanSubmit() {//tScaner.JpegQuality = 30; //jpg图像质量//tScaner.ScanImageLeft=10; //扫描图像的位置(厘米)//tScaner.ScanImageTop=10; //扫描图像的位置(厘米)//tScaner.ScanImageWidth=20.0;//扫描图像的宽度 厘米//tScaner.ScanImageHeight=10.2;//扫描图像的高度 厘米if (tScaner.Scan($("#cbo_set").is(":checked")&&scanidx==1) == 0) { //仅在第一次扫描时显示设置界面//tScaner.Scan(true) //扫描前显示扫描设置界面var imgBase64 = tScaner.ScanImageData;if (imgBase64 != "") {//添加到列表$("#scanFileList").append("<div id='f_" + scanidx + "' style='width:80px;height:100px;margin-left:2px;float:left;border:solid 1px #ccc;'><img src='' width='80' height='100' /></div>");//上传图像$.post("fileup.aspx", { img: imgBase64, id: scanidx }, function(dat) {$("#f_" + dat.id + " img").attr("src", dat.src);}, "json");}//是否连续扫描if ($("#cbo_lxsm").is(":checked")) {scanSubmit();}} }

服务器端(fileup.aspx)接收文件代码(用户可以根据需要转换为java、php等不同语言以适应现有的系统环境)

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 + "'}");}

在线演示地址文件连续扫描、摄像头抓拍

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。