How to print (barcode) shortcuts from a Ruby on Rails application?

My first application developed by me at RoR is for some Kiosk touchscreen PCs used in our warehouse. When the exchange worker takes the material, he enters the quantity in the form.
Now I want to print a label containing: customer name, material description, quantity and barcode on our Zebra printer.
How can I do this from a Ruby on Rails application?

  • Send directly control characters required for ZPL (Zebra Printer Language) from the controller? (not very comfortable)

  • Create a view in HTML, send it to the client, and the client must print it. (not very convenient and error prone, as the exchange worker must take additional steps, may choose the wrong printer, or maybe not print the label at all)

  • Create a pdf document from the controller and send it to the printer from the server (oh no, the printer does not understand pdf, so I need to control the PDF reader to print? T be very fast, because it will send the label as a graphic image to the printer

  • Create a gem that hides all the logic needed for printing? (Are there any gems that already do this?)

I would be grateful for every comment.

thanks

Klaus

+4
source share
4 answers

I would send the raw ZPL to the printer. You can use a tool like Bartender (I would suggest installing Bartender Only with this link. You can basically create your own shortcut in this tool. You designed your label, you downloaded the printer drivers for your zebra printer and installed a dummy printer with these drivers and printed this shortcut that you created for the file. This will give you raw zpl. From this you can basically replace all the dynamic data in the zpl file that you printed in the previous step and send it directly to the printer via Serial Port, tcp / ip or usb.

+4
source

Edit: I found a much better solution as I continued to delve into this. This has been pretty significantly edited to focus on the Java applet solution I used.

Basically, you will create a shortcut as raw ZPL text. Then you need to get this plain text on the printer that will generate the label.

If your server can access the IP address of the printer, you can copy the ZPL to the printer directly from the server process. If this is a remote web application, you need to get the client to send the ZPL for you. Browser isolation makes this difficult, so drivers want to help. There are several options; the most common is to use a small Java or Flash applet to actually copy. If you can get a specific web browser that your users use to print on a text printer without adding anything, you can use local printing, but usually the most reliable approach is to use a helper Java applet.

The Java applet I use for this is jZebra: http://code.google.com/p/jzebra/

This is a very clean and easy approach, look at the HTML sample in the download package and type a shortcut in a few lines of code. I just edited a sample and plan to use it as a popup popup. It's really that simple.

Two caveats with this approach:

  • Your users must have JRE installed
  • jZebra finds a Zebra printer by printer name. There are very specific guides (they have detailed instructions for setting up Mac, Windows, and Linux) for what you need to do, but this is well documented, and you just need your users to follow the instructions. After properly configured, it works great.
+2
source

A simpler solution, and I think it’s better. Typically, most browsers and machines have a PDF viewer. Therefore, simply create shortcuts as PDF documents and send them to your browser.

We performed label printing using the Zebra printer in ROR as follows.

  • Create html format exact label pages.
  • Convert html to pdf using wickedPDF.

Typically, tags contain barcodes.

So a general solution would be,

  • Create barcodes using Barbie jewelry.
  • Create html with barcodes and your data that should be displayed on the label.
  • Convert html view to pdf.
+1
source

Sounds like work to extend ruby ​​C. Perhaps one that also wraps something like gnu barcode http://www.gnu.org/software/barcode/ and some other open standard for a zebra printer, if one exists? I once made a rails application that made coupons and heavily used gnu barcode, but I made a simple shell command to interact with it.

0
source

Source: https://habr.com/ru/post/1346447/


All Articles