php 生成和读取条码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7894228/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 03:35:37  来源:igfitidea点击:

Generating and reading barcode

phpmysqldatabasewebbarcode

提问by heron

I've built an e-shopping website for a big company which has country offices.

我为一家设有国家办事处的大公司建立了一个电子购物网站。

What i want to do is the following

我想做的是以下

  1. Generate barcode via PHP before sending package to country offices of company
  2. When the item will be arrived to country office, workers will login to their account, scan this barcode via barcode reader (which located on package) and website will automatically "approve" that item received.
  1. 在将包裹发送到公司的国家办事处之前通过 PHP 生成条形码
  2. 当物品到达国家办事处时,工作人员将登录他们的帐户,通过条形码阅读器(位于包装上)扫描此条形码,网站将自动“批准”收到的物品。

Is it possible only with web interface? I mean without any local application. How to do that? PLease explain.

是否只能使用 Web 界面?我的意思是没有任何本地应用程序。怎么做?请解释。

回答by sled

so here is an approach that could work for you:

所以这里有一种方法可以为您工作:

You need to put a record in a database like:

您需要将记录放入数据库中,例如:

package_id |    name      |   status

  1234        My Package      shipped
package_id |    name      |   status

  1234        My Package      shipped

Generate a barcode which contains the package_id, you have to decide what kind of barcode you want to use. You could also use a data matrix. Then you create the bar code as image so that you can print it. Data Matrix is very good for large custom data.

生成包含 package_id 的条形码,您必须决定要使用哪种条形码。您也可以使用数据矩阵。然后您将条形码创建为图像,以便您可以打印它。Data Matrix 非常适合大型自定义数据。

Print the bar code, put it on your package

打印条形码,将其放在您的包裹上

The package arrives at the office, the user logs on to your website, clicks on "Confirm Package Received" or whatever. Then there is a text-field, he focuses the text-field, scans the barcode/data matrix and your package ID "1234" will appear in the text-field

包裹到达办公室,用户登录您的网站,点击“确认包裹已收到”或其他任何内容。然后是一个文本字段,他聚焦文本字段,扫描条形码/数据矩阵,您的包裹 ID“1234”将出现在文本字段中

Submit the form, lookup the entry in the database, change it to:

提交表单,在数据库中查找条目,修改为:

 package_id |     name      |   status
  1234         My Package      delivered

A TipIf you use a QR Codeit can be read by many mobile phones, so you don't need a real bar code scanner. You could write an app that reads the bar code and sends the package_id to your server.

提示如果您使用二维码,它可以被许多手机读取,因此您不需要真正的条形码扫描仪。您可以编写一个应用程序来读取条形码并将 package_id 发送到您的服务器。

回答by Lajos Veres

Tcpdf has a few classes for generating barcodes:

Tcpdf 有几个用于生成条码的类:

http://www.tcpdf.org/doc/code/classTCPDFBarcode.html

http://www.tcpdf.org/doc/code/classTCPDFBarcode.html

With good examples:

有很好的例子:

http://www.tcpdf.org/examples.php

http://www.tcpdf.org/examples.php

For example the first:

例如第一个:

// set the barcode content and type
$barcodeobj = new TCPDFBarcode('http://www.tcpdf.org', 'C128');

// output the barcode as HTML object
echo $barcodeobj->getBarcodeHTML(2, 30, 'black');

回答by JMS786

Check larsjung.de/qrcode/?

检查larsjung.de/qrcode/?

It's JQuery Pluggin, but works well with PHP.

它是 JQuery 插件,但适用于 PHP。

As I see your scenario, you need more than just 1D Barcode. You need QR Code.

正如我所看到的,您需要的不仅仅是一维条码。您需要二维码。

Hope this helps.

希望这可以帮助。

回答by jsgoupil

First, you need to chose which barcode type you want to generate. There are multiple to consider, 1D or 2D. 1D barcodes are simple encode only a small amount of data. 2D barcodes are bigger and can encode more data, they are also a little more aesthetic :) If you go for a 2D barcodes, I would recommend QRCode, or DataMatrix. The PDF417 is a viable option if you need to lay your data more horizontally instead of squared. You can find more information here: http://www.barcodebakery.com/en/resources/guide/php/choosing-barcodes

首先,您需要选择要生成的条形码类型。有多个需要考虑,一维或二维。一维条形码很简单,只对少量数据进行编码。二维条码更大,可以编码更多数据,它们也更美观:) 如果您选择二维条码,我会推荐 QRCode 或 DataMatrix。如果您需要更水平地而不是方形地放置数据,PDF417 是一个可行的选择。您可以在此处找到更多信息:http: //www.barcodebakery.com/en/resources/guide/php/choosing-barcodes

Once you found your code to write, you consider which reader to get. I currently own a Metrologic Focus FirstFlash MS1690. It reads all the barcodes mentioned above. They are multiple options here again, the easiest is to get a USB barcode reader: when you scan a barcode, it would simply write it to the screen as someone were typing it on the keyboard.

找到要编写的代码后,您就要考虑使用哪个阅读器。我目前拥有一台 Metrologic Focus FirstFlash MS1690。它读取上面提到的所有条形码。它们在这里又是多种选择,最简单的方法是使用 USB 条码阅读器:当您扫描条码时,它会简单地将其写入屏幕,就像有人在键盘上打字一样。

回答by dkinzer

I'm looking at Zend barcodeto do something similar, but admittedly I'm only getting started. I'm eager to know how others handle this.

我正在查看Zend 条码来做类似的事情,但不可否认,我才刚刚开始。我很想知道其他人如何处理这个问题。

回答by user2826831

This is possible to make using php only. For this you need to take any ready php class to generate qr-code or barcode. Generating barcode may be performed with means of just selecting appropriate bacode font, so, instead of writting numbers php will be writing by barcoded digits. Reading of barcode was described above.

这可以仅使用 php 来实现。为此,您需要使用任何准备好的 php 类来生成二维码或条形码。生成条码可以通过只选择合适的 bacode 字体来执行,因此,php 将用条码数字写入,而不是写数字。条形码的读取如上所述。

回答by dnagirl

I'm not sure if I completely understand your question, but if you are looking make a file that can be printedas a barcode, you'll need to know what kind of files your barcode printer can print.

我不确定我是否完全理解你的问题,但如果你正在寻找一个可以打印为条形码的文件,你需要知道你的条形码打印机可以打印什么样的文件。

And if you are looking to reada barcode with a scanner into a webform, the scanner needs to recognize the barcode type. The scanner inputs the barcode value into the webform (or any other program that accepts text). The webform has nothing to do with recognizing a barcode.

如果您希望使用扫描仪将条形码读取到网络表单中,则扫描仪需要识别条形码类型。扫描仪将条形码值输入到网络表单(或任何其他接受文本的程序)中。网络表单与识别条形码无关。