从网页到 Zebra 打印机打印条码 [英] Print barcodes from web page to Zebra printer

查看:71
本文介绍了从网页到 Zebra 打印机打印条码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试将网页上的条形码打印到我们的 Zebra 打印机.

我想知道是否有办法使用打印机自己的字体打印它们,或者使用网络字体,或​​者我是否知道使用的字体名称?

我一直在尝试使用 php 条形码生成器,它基本上生成包含条形码的图像.事实上,我已经尝试这种方法几天了,但没有成功.

问题是当我打印它们时,扫描仪无法读取.我尝试更改图像分辨率以匹配打印机(203dpi)的分辨率,也尝试使用图像大小和格式,但打印后的条形码仍然无法扫描.

那么有人有这方面的经验吗?

打印机:Zebra TLP 2844

每页所需的条形码:

  • 01 Code39 水平(仅在以非常特定的尺寸和浏览器打印时才可扫描)
  • 01 Code128 垂直(仍然无法正常工作,打印总是很模糊,无法扫描)

============

我取得了一些进展,我发现这台打印机支持 EPL2 语言,所以我想用它来打印条码.

首先我需要启用直通模式,我在打印机选项 > 高级设置 > 杂项中做到了这一点.

现在我可以使用打印机的内置字体完美打印条码 :D 使用以下命令:

ZPL:B10,10,0,1,2,2,60,N,"TEXT-GOES-HERE":ZPL

但是我只能用记事本打印它,我仍然无法从浏览器打印它......这可能是LF被CR+LF替换的问题......

如何克服这个问题??

============

我尝试打印的标签实际上在条形码之前有一些文本,一些 html 表格对其进行了很好的格式化.所以我需要先打印这个,在中间我需要贴上一个漂亮的标签,然后再添加一些文字.

所以我不能使用纯 EPL2 来打印整个东西,我想知道我是否可以使用 html + EPL2 + html 中的一些来实现我的目标,还是不允许?=/

解决方案

您遇到了一些障碍:

1) 当您通过 OS 安装的打印机驱动程序打印时,打印机驱动程序会尝试获取发送给它的数据并(重新)光栅化或缩放它以用于输出设备(Zebra 打印机).由于打印机在 203dpi 时的分辨率相对较低,因此打印驱动程序必须执行的缩放操作不会花费太多时间来降低条码质量的完整性.这就是使用直接 ZPL 命令生成的条形码更可靠的原因.

2) 由于网络浏览器通过不允许访问客户端计算机而有意提供的安全性,您无法直接与客户端连接的打印机进行通信.这种沙箱有助于保护用户免受恶意软件的侵害,从而使恶意网站无法执行诸如将文件写入客户端计算机或将输出直接发送到打印机等设备之类的操作.因此,您无法通过浏览器直接将 ZPL 命令发送到客户端连接的打印机.

但是,有一种方法可以执行您所描述的操作.必要的步骤通常只有在您对访问站点的客户端计算机有一定程度的控制时才有用,该站点尝试使用 Zebra 打印机进行打印.例如,这只会被您公司网络上的机器使用,或者被愿意安装您需要编写的小应用程序的客户使用.为此,您需要查看以下步骤:

A) 您需要创建自己的自定义 MIME 类型.这基本上只是您想使用的任何名称,不会与任何注册的 MIME 类型.

B) 接下来,您将定义一个将映射到您的自定义 MIME 类型的文件扩展名.为此,您通常需要配置您的网络服务器(具体步骤取决于您使用的网络服务器)以允许您要定义的新 MIME 类型以及用于这些类型文件的文件扩展名.

C) 然后在您的 Web 应用程序上,当您想要输出 ZPL 数据时,您可以使用映射到新 MIME 类型的文件扩展名将其写入文件.然后,一旦文件生成,您可以提供指向它的 HTML 链接,或将客户端浏览器重定向到该文件.您可以通过手动将您创建的文件直接复制到原始打印机端口来测试您的文件此时是否正常工作.

D) 接下来您需要编写一个可以安装在客户端的小应用程序.安装应用程序后,您需要将其注册为自定义 MIME 类型的有效消费应用程序.如果浏览器检测到有指定 MIME 类型文件的已安装应用程序,它只需将该文件写入客户端计算机上的临时目录,然后尝试使用该临时文件启动相同已注册 MIME 类型的应用程序应用程序的参数.因此,您的应用程序现在只读取浏览器传递给它的文件,然后尝试将其直接转储到打印机.

这是为了完成您所描述的事情您需要做什么的概述.某些特定步骤将取决于您使用的 Web 服务器类型以及您的客户端机器是什么操作系统.但这是让您完成您正在尝试的工作的高级概述.

We're trying to print barcodes from a web page to our Zebra printer.

I'm wondering if there's a way to print them using the printer's own font perhaps using web fonts or if I knew the font name used?

I have been trying to use php barcode generators, that basically generates images containing the barcode. I have in fact been trying this approach for a few days already, without success.

The problem is when I print them it's not readable by the scanners. I have tried to change the image resolution to match that of the printer (203dpi), also tried playing with the image size and formats, but the barcodes after printed still can't be scanned.

So does anybody have experience with this?

Printer: Zebra TLP 2844

Barcodes required per page:

  • 01 Code39 horizontal (scanable only if printed at very specific size and browser)
  • 01 Code128 vertical (still can't get it to work, print is always very blurry and won't get scanned)

===========

I've made a little bit of progress, I found out this printer supports EPL2 language, so I'm trying to use it to print out the barcodes.

First I needed to enable pass through mode, I did that on Printer Options > Advanced Setup > Miscellaneous.

Now I'm able to print barcodes impeccably using the printer's built-in font :D using this command:

ZPL: B10,10,0,1,2,2,60,N,"TEXT-GOES-HERE" :ZPL

But I can only print it from Notepad, I'm still unable to print this from a browser... It's probably a problem with LF being replaced with CR+LF...

How to overcome this problem??

===========

The label I'm trying to print actually has a bit of text before the barcode, with some html tables formatting it nicely. So I need to print this first, and in the middle I need to stick in a nice label and then add some more text.

So I can't use pure EPL2 to print the whole thing, I'm wondering if I can use some of both html + EPL2 + html to achieve my goal or is that not allowed?? =/

解决方案

You are running into a few obstacles:

1) When you print through the OS installed printer driver, the printer driver is trying to take the data that is sent to it and (re)rasterize or scale it for the output device (the Zebra printer). Since the printer is a relatively low resolution at 203dpi, then it does not take too much for the scaling the print driver is having to do for it to loose some integrity in the quality of the barcode. This is why barcodes generated using the direct ZPL commands are much more reliable.

2) Due to the security that web browsers purposefully provide by not allowing access to the client computer, you cannot directly communicate with the client connected printer. This sandboxing is what helps to protect users from malware so that nefarious websites cannot do things like write files to the client machine or send output directly to devices such as printers. So you are not able to directly send the ZPL commands through the browser to the client connected printer.

However, there is a way to do what you describe. The steps necessary are typically only going to be useful if you have some degree of control over the client computer accessing the site that is trying to print to the Zebra printers. For example this is only going to be used by machines on your company network, or by clients who are willing to install a small application that you need to write. To do this, you will need to look at the following steps:

A) You need to make up your own custom MIME type. This is basically just any name you want to use that is not going to collide with any registered MIME types.

B) Next you will define a filename extension that will map to your custom MIME type. To do this, you typically will need to configure your web server (steps for this depend on what web server you are using) to allow the new MIME type you want to define and what file extension is used for these types of files.

C) Then on your web application, when you want to output the ZPL data, you write it to a file using a filename extension that is mapped to your new MIME type. Then once the file is generated, you can either provide an HTML link to it, or redirect the client browser to the file. You can test if your file is working correctly at this point by manually copying the file you created directly to the raw printer port.

D) Next you need to write a small application which can be installed on the client. When the application is installed, you need to have it register itself as a valid consuming application for your custom MIME type. If a browser detects that there is an installed application for a file of the specified MIME type, it simply writes the file to a temporary directory on the client machine and then attempts to launch the application of the same registered MIME type with the temporary file as a parameter to the application. Thus your application now just reads the file that the browser passed to it and then it attempts to dump it directly to the printer.

This is an overview of what you need to do in order to accomplish what you are describing. Some of the specific steps will depend on what type of web server you are using and what OS your clients machines are. But this is the high level overview that will let you accomplish what you are attempting.

这篇关于从网页到 Zebra 打印机打印条码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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