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

查看:682
本文介绍了将条形码从网页打印到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)当您通过操作系统安装的打印机驱动程序进行打印时,打印机驱动程序正在尝试获取发送给它的数据,并对输出设备(Zebra打印机)进行(重新)光栅化或缩放.由于打印机的分辨率为203dpi,因此分辨率相对较低,因此缩放打印驱动程序不必花太多时间,以使打印机在条形码质量方面失去一些完整性.这就是使用直接ZPL命令生成的条形码更可靠的原因.

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

但是,有一种方法可以做您描述的事情.仅当您对客户端计算机访问尝试打印到Zebra打印机的站点的客户端计算机有一定程度的控制权时,通常只有必要的步骤才有用.例如,这仅将由公司网络上的计算机或愿意安装需要编写的小型应用程序的客户端使用.为此,您需要查看以下步骤:

A)您需要组成自己的自定义MIME类型.基本上,这只是您要使用的任何名称,不会与任何已注册的MIME类型相冲突.

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

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

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

这是完成您所描述的内容所需做的概述.某些特定步骤将取决于您使用的Web服务器类型以及客户端计算机所使用的OS.但这是高层次的概述,可让您完成正在尝试的工作.

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天全站免登陆