扫描文件 [英] Scanning a Document

查看:66
本文介绍了扫描文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用javascript从我的Web应用程序中扫描文档.
我该怎么做.

I want to scan a document from my web application using javascript.
How can I do this.

推荐答案

您是什么意思? Web应用程序通常不可能直接从扫描仪检索图像.用户应使用其自己的扫描仪软件将其存储为图像文件.然后可以上传图像文件.

祝你好运!
How do you mean? It is normally not possible for a web application to retrieve an image directly from a scanner. The user should use it''s own scanner software to store it as an image file. The image file can then be uploaded.

Good luck!


我找到了一种扫描文档但不使用Javascript的解决方案.
这是它的代码.

I found one solution for scanning Documents but not using Javascript.
Here is the code for it.

WiaClass wiaManager = null;		// WIA manager COM object
CollectionClass wiaDevs = null;		// WIA devices collection COM object
ItemClass wiaRoot = null;		// WIA root device COM object
CollectionClass wiaPics = null;		// WIA collection COM object
ItemClass wiaItem = null;		// WIA image COM object
try
    {
      string fileName = "myFile";
      wiaManager = new WiaClass();	// create COM instance of WIA manager

  wiaDevs = wiaManager.Devices as CollectionClass;// call Wia.Devices to get all devices

   if ((wiaDevs == null) || (wiaDevs.Count == 0))
   {
        Response.Write("<script>alert(''No Scanner found'');</script>");
        return;
   }
   else
   {
       object selectUsingUI = System.Reflection.Missing.Value;			
       wiaRoot = (ItemClass)wiaManager.Create(ref selectUsingUI);//letUser select device
       
     if(wiaRoot == Null	)
        return;

    // this call shows the common WIA dialog to let the user select a picture:
     wiaPics = wiaRoot.GetItemsFromUI(WiaFlag.SingleImage, WiaIntent.ImageTypeColor) as     CollectionClass;
              
      if (wiaPics == null)
            return;
      bool takeFirst = true;	         // this sample uses only one single picture
      string ImgName = Server.MapPath("~\\thumbnails").ToString() + "\\" + fileName;
    
     foreach (object wiaObj in wiaPics)	// enumerate all the pictures the user selected
      {
          if (takeFirst)
          {
          wiaItem = (ItemClass)Marshal.CreateWrapperOfType(wiaObj, typeof(ItemClass));
          // transfer picture to our temporary file
          wiaItem.Transfer(ImgName + ".jpg", false); 
          makeThumbnail(fileName + ".jpg");        
     takeFirst = false;								
    }
    Marshal.ReleaseComObject(wiaObj);		
   }
}
}
catch (Exception ee)
{
}
finally
(
if (wiaItem != null)
    Marshal.ReleaseComObject(wiaItem);		// release WIA image COM object
if (wiaPics != null)
    Marshal.ReleaseComObject(wiaPics);		// release WIA collection COM object
if (wiaRoot != null)
    Marshal.ReleaseComObject(wiaRoot);		// release WIA root device COM object
if (wiaDevs != null)
    Marshal.ReleaseComObject(wiaDevs);	// release WIA devices collection COM object
if (wiaManager != null)<pre>


元帅.ReleaseComObject(wiaManager); //释放WIA管理器COM对象
}


Marshal.ReleaseComObject(wiaManager); // release WIA manager COM object
}


这篇关于扫描文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆