简体   繁体   English

C#扫描仪扫描条形码

[英]c# scanner scan barcode

I'm now trying to create an web application or software, whatever, by c# to achieve a process -- when I scan a piece of paper(contains barcode) using my office scanner, the software or web application will automatically get the the barcode content. 我现在正在尝试通过c#创建一个Web应用程序或软件,以实现流程-当我使用办公室扫描仪扫描一张纸(包含条形码)时,该软件或Web应用程序将自动获取条形码内容。

I'm now a bit confusing of how to achieve this. 我现在对如何实现这一点感到困惑。 Anyone has idea about this? 有人对此有想法吗? Do I need to call the Scanner's API or something? 我需要调用扫描仪的API或其他东西吗? My scanner brand is EPSON. 我的扫描仪品牌是EPSON。

Thanks in advance. 提前致谢。

This will give you a general idea on creating your desired application 这将为您提供有关创建所需应用程序的总体思路

  • At first you have to capture the image from the scanner using TWAIN or using Windows image Acquistion 首先,您必须使用TWAINWindows图像采集从扫描仪捕获图像。
  • Then you have to read the bar code from the image.You can use some third party libraries to read the barcode. 然后,您必须从图像中读取条形码。您可以使用一些第三方库来读取条形码。

Some of the articles that will help you.. 一些将对您有所帮助的文章。

Barcode scanners automatically decode the Bars and return a string! 条形码扫描仪会自动解码条形码并返回一个字符串! Try using in Ms-Word or Notepad. 尝试在Ms-Word或记事本中使用。 The string is followed by return in some barcode readers. 在某些条形码阅读器中,该字符串后跟return

Actually we do not normally do it coz it will dramatically reduce application performance. 实际上,我们通常不这样做,因为它将大大降低应用程序性能。 Let's say for example, if you scan two files at the same time, the time gap is too short, scanner won't have the mechanism to separate two files. 举例来说,如果您同时扫描两个文件,则时间间隔太短,扫描仪将没有分离两个文件的机制。

Thus my suggestion of this would be create a web app, manually upload the document and process. 因此,我对此的建议是创建一个Web应用程序,手动上传文档和过程。

With Asprise C# VB.NET Scanning & Imaging SDK , you can acquires images from TWAIN WIA scanners and extract barcodes at the same time - even if your scanner doesn't support reading barcode natively. 使用Asprise C#VB.NET扫描和图像SDK ,即使您的扫描仪不支持本地读取条形码,也可以从TWAIN WIA扫描仪获取图像并同时提取条形码。

The code snippet below saves the scanned images into a multi-page PDF file at the current working directory and prints the barcodes recognized: 下面的代码段将扫描的图像保存到当前工作目录下的多页PDF文件中 ,并打印识别出的条形码:

Result result = new AspriseImaging().Scan(new Request()
  .SetTwainCap(TwainConstants.ICAP_PIXELTYPE, TwainConstants.TWPT_RGB) // color mode
  .SetTwainCap(TwainConstants.ICAP_SUPPORTEDSIZES, TwainConstants.TWSS_USLETTER) // paper size
  .SetRecognizeBarcodes(true)
  .AddOutputItem(new RequestOutputItem(AspriseImaging.OUTPUT_SAVE, AspriseImaging.FORMAT_PDF).SetSavePath(".\\${TMS}${EXT}")),
 "select", true, true);

List<string> barcodes = result == null ? null : result.GetBarcodes();
Console.WriteLine("Barcodes: " + string.Join(";\n", barcodes == null ? new string[0] : barcodes.ToArray()));

// Alternatively, request can be specified using the following JSON:
{
   "twain_cap_setting" : 
    {
      "ICAP_PIXEXELTYPE" : "TWPT_RGB",
      "ICAP_SUPPORPORTEDSIZES" : "TWSS_USLESLETTER"
    }, 
   "recognize_barcodes" : true,
   "output_settings" : [ {
     "type" : "save",
     "format" : "pdf",
     "save_path" : ".\\${TMS}${EXT}"   } ]
 }

Download and run the reading barcodes while scanning from TWAIN scanners demos here. 此处的TWAIN扫描仪演示扫描时,下载并运行读取条形码

Refer to the developer's guide to C# VB.NET scanning and imaging API for more details. 有关更多详细信息,请参考C#VB.NET扫描和成像API开发人员指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM