将条形码扫描仪集成到php应用程序中? [英] integrating barcode scanner into php application?

查看:252
本文介绍了将条形码扫描仪集成到php应用程序中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们一直在用php开发Web应用程序.
我们需要将条形码扫描仪集成到我们的应用程序中.

We have been developing web application in php.
We need barcode scanner to be integrated into our application.

我们的应用程序分为用户和商家两个模块.

Our application is divided into two modules, users and merchant.

当用户来扫描卡时,应通过条形码识别商户.管理员将提供条形码编号,该条形码编号将被发送到卡制造商,并且该编号将分配给磁条.

When user comes and scans the card, merchant should be identified the user by barcode number. Admin will give barcode number and that is being sent to the card manufacturer and the number will be assigned to the magnetic stripe.

据我所知,扫描仪可以用作键盘,能否请您告诉将条形码扫描仪集成到此基于php web的应用程序中的方法?

As i know scanner can acts as a key board, can you please tell the method to integrate barcode scanner into this php web based application?

推荐答案

PHP可以轻松地用于读取打印在纸质文档上的条形码.通过USB将手动条形码阅读器连接到计算机,可将PHP(或任何其他网络编程语言)的可用性大大扩展到涉及文档和产品管理的任务,例如在数据库中查找书籍记录或列出特定客户的所有账单.

PHP can be easily utilized for reading bar codes printed on paper documents. Connecting manual barcode reader to the computer via USB significantly extends usability of PHP (or any other web programming language) into tasks involving document and product management, like finding a book records in the database or listing all bills for a particular customer.

以下各节简要介绍了使用PHP连接和使用手动条形码阅读器的过程.

Following sections briefly describe process of connecting and using manual bar code reader with PHP.

本文中描述的条形码扫描仪的用法在 适用于任何网络编程语言(例如ASP)的方法相同, Python或Perl.由于仅进行了所有测试,因此本文仅使用PHP. 用PHP应用程序完成.

The usage of bar code scanners described in this article are in the same way applicable to any web programming language, such as ASP, Python or Perl. This article uses only PHP since all tests have been done with PHP applications.

什么是条形码阅读器(扫描仪)

条形码阅读器是可插入计算机的硬件,可将解码后的条形码字符串发送到计算机.诀窍是要知道如何捕获接收到的字符串.使用PHP(和任何其他Web编程语言)时,字符串将被放置到浏览器中的焦点输入HTML元素中.因此,要捕获收到的条形码字符串,必须执行以下操作:

Bar code reader is a hardware pluggable into computer that sends decoded bar code strings into computer. The trick is to know how to catch that received string. With PHP (and any other web programming language) the string will be placed into focused input HTML element in browser. Thus to catch received bar code string, following must be done:

在阅读条形码之前,必须将正确的输入元素(例如输入文本字段")聚焦(鼠标光标在输入字段的内部). 一旦专注,就开始阅读代码 当识别出代码时(条形码阅读器通常会发出短促的哔哔声),它会被发送到关注的输入字段.默认情况下,大多数条形码读取器会将额外的特殊字符附加到解码后的称为CRLF(ENTER)的条形码字符串中.例如,如果解码的条形码是"12345AB",则计算机将收到"12345AB ENTER ".附加字符 ENTER (或 CRLF )模拟按下ENTER键,导致立即提交HTML表单:

just before reading the bar code, proper input element, such as INPUT TEXT FIELD must be focused (mouse cursor is inside of the input field). once focused, start reading the code when the code is recognized (bar code reader usually shortly beeps), it is send to the focused input field. By default, most of bar code readers will append extra special character to decoded bar code string called CRLF (ENTER). For example, if decoded bar code is "12345AB", then computer will receive "12345ABENTER". Appended character ENTER (or CRLF) emulates pressing the key ENTER causing instant submission of the HTML form:

<form action="search.php" method="post">
    <input name="documentID" onmouseover="this.focus();" type="text">
</form>

选择合适的条形码扫描器

选择条形码阅读器时,应考虑将使用哪种类型的条形码阅读器.有些条形码只允许数字,有些则没有校验和,有些条形码很难用喷墨打印机打印,有些条形码阅读器的阅读窗格狭窄,无法读取长度超过10厘米的条形码.大多数条形码读取器都支持常见的条形码,例如EAN8,EAN13,CODE 39,Interleaved 2/5,Code 128等.

When choosing bar code reader, one should consider what types of bar codes will be read with it. Some bar codes allow only numbers, others will not have checksum, some bar codes are difficult to print with inkjet printers, some barcode readers have narrow reading pane and cannot read for example barcodes with length over 10 cm. Most of barcode readers support common barcodes, such as EAN8, EAN13, CODE 39, Interleaved 2/5, Code 128 etc.

出于办公目的,最合适的条形码似乎是支持所有字母数字字符的条形码,可能是:

For office purposes, the most suitable barcodes seem to be those supporting full range of alphanumeric characters, which might be:

  • 代码39-支持0-9,大写字母A-Z和少量特殊字符(破折号,逗号,空格,$,/,+,%,*)
  • 代码128-支持0-9,a-z,A-Z和其他扩展字符

其他重要注意事项:

  • 确保支持所有标准条形码,至少是CODE39,CODE128,Interleaved25,EAN8,EAN13,PDF417,QRCODE.
  • 仅使用标准USB插件电缆. RS232接口旨在用于工业用途,而不是连接到单台PC.
  • 电缆应足够长,至少1.5 m-越长越好.
  • 插入计算机的
  • 条形码阅读器不需要其他电源-只需通过USB连接到PC即可上电.
  • 如果您还需要将条形码打印到生成的PDF文档中,则可以使用支持大多数常见2D条形码的TCPDF开源库.
  • make sure all standard barcodes are supported, at least CODE39, CODE128, Interleaved25, EAN8, EAN13, PDF417, QRCODE.
  • use only standard USB plugin cables. RS232 interfaces are meant for industrial usage, rather than connecting to single PC.
  • the cable should be long enough, at least 1.5 m - the longer the better.
  • bar code reader plugged into computer should not require other power supply - it should power up simply by connecting to PC via USB.
  • if you also need to print bar code into generated PDF documents, you can use TCPDF open source library that supports most of common 2D bar codes.

安装扫描仪驱动程序

安装手动条形码阅读器需要安装适用于您特定操作系统的驱动程序,并且通常应随购买的条形码阅读器一起提供.

Installing manual bar code reader requires installing drivers for your particular operating system and should be normally supplied with purchased bar code reader.

一旦安装好并准备就绪,条形码阅读器就会打开LED信号灯.读取条形码始于按下按钮进行读取.

Once installed and ready, bar code reader turns on signal LED light. Reading the barcode starts with pressing button for reading.

扫描条形码-如何工作?

步骤1 -聚焦的输入字段已准备就绪,可以从条形码扫描仪接收字符流:

STEP 1 - Focused input field ready for receiving character stream from bar code scanner:

第2步-从条形码扫描仪收到的条形码字符串会立即提交以搜索到数据库中,从而产生很好的自动"效果:

STEP 2 - Received barcode string from bar code scanner is immediatelly submitted for search into database, which creates nice "automated" effect:

第3步-使用提交的条形码搜索数据库后返回的结果:

STEP 3 - Results returned after searching the database with submitted bar code:

结论

看来,到目前为止,使用PHP(实际上是任何Web编程语言)来扫描条形码的方法还是被完全忽略了.但是,有了模拟按键(ENTER/CRLF)的自然支持,就很容易实现自动化的收集和处理.通过简单的HTML(GUI)格式处理识别的条形码字符串.

It seems, that utilization of PHP (and actually any web programming language) for scanning the bar codes has been quite overlooked so far. However, with natural support of emulated keypress (ENTER/CRLF) it is very easy to automate collecting & processing recognized bar code strings via simple HTML (GUI) fomular.

关键是要了解,已识别的条形码字符串会立即发送到焦点HTML元素,例如带有尾随字符ASCII 13(= ENTER/CRLF,可配置的选项)的INPUT文本字段,该字段立即发送输入文本字段将填充的接收到的条形码作为HTML公式添加到任何其他脚本中,以进行进一步处理.

The key is to understand, that recognized bar code string is instantly sent to the focused HTML element, such as INPUT text field with appended trailing character ASCII 13 (=ENTER/CRLF, configurable option), which instantly sends input text field with populated received barcode as a HTML formular to any other script for further processing.

参考:http://www.synet .sk/php/en/280-barcode-reader-scanner-in-php

希望这对您有所帮助:)

Hope this helps you :)

这篇关于将条形码扫描仪集成到php应用程序中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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