How to print (barcode) labels from a Ruby on Rails Application? - ruby-on-rails

My first application I have developed in RoR is for some Kiosk Touchscreen PCs used in our stock. When the stock worker picked up some material he enters the quantity in a Form.
Now I want to print a label containing: customer name, material description, quantity, and a barcode on our Zebra printer.
How would I do that from a Ruby on Rails Application ?
Sending directly the control chars needed for ZPL (Zebra Printer Language) from the controller ? ( not very comfortable )
Create a view in HTML send it to the client, and the client has to print it. ( not very confortable and error prone, as the stock worker has to do additional steps, may choose the wrong printer or maybe don't 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 have to control a pdf reader to do the printing ?? That wouldn't be very fast as it will send the label as a graphic image to the printer
Create a gem which will hide all the logic needed for printing ? ( Are there any gems which already do this ? )
I would appreciate every comment.
Thanks
Klaus

I would send the raw ZPL to the printer. You can use a tool like Bartender (I would suggest installing Bartender Only from that link. You can basically design your label in this tool. After you've designed your label you would download the bartender printer drivers for your zebra printer and set up a dummy printer with these drivers and print this label you designed to a file. This will give you the raw zpl. From this you can basically substitute all the dynamic data into the zpl file you printed in the previous step and send this directly to the printer via serial, tcp/ip or usb.

Edit: I found a much better solution as I continued to dig on this. This is pretty significantly edited down to focus on the Java applet solution I ended up using.
Basically, you will generate the label as raw ZPL text. You then need to get that plain text to the printer, which will generate the label.
If your server can access the printer's IP address, you can copy the ZPL to the printer directly from the server process. If it's a remote web app, you need to get the client to send the ZPL for you. Browser sandboxing makes this hard to pull off - drivers want to helpfully get in the way. There are a few options; the most common is to use a small Java or Flash applet to do the actual copying. If you can get the specific web browser your users are using to print to a plain text printer without adding anything, you could use local printing, but generally the most robust approach is to use a helper Java applet.
The Java applet I use for this is jZebra: http://code.google.com/p/jzebra/
It's a very clean & straightforward approach, look at the sample HTML in the download package and a few lines of code print the label. I just edited down the sample and am planning to use it as my production code popup.. it's really that straightforward.
Two caveats with this approach:
Your users must have the JRE installed
jZebra finds the Zebra printer by printer name. There are very specific guides (they have detailed instructions for Mac, Windows, and Linux setup) for what you need to do - but it's well documented and you just have to have your users follow the instructions. Once it's set up correctly it works great.

More simple solution, and I believe better as well, Usually most of browser and machines has PDF viewer installed. So just create labels as PDF documents and sent it to browser.
We have implemented label printing using Zebra printer in ROR following way.
Create exact format label pages in html.
Convert the html to pdf using wickedPDF.
Usually labels contains barcodes as well.
So overall solution would be,
Create barcodes using barbie gem.
Create html using barcodes and your actuall data that needs to go on label.
Convert html view to PDF.

Sounds like a job for a ruby C extension. Perhaps one that also wraps something like gnu barcode http://www.gnu.org/software/barcode/ library and some other open standard for the zebra printer, if one exists? I once did a rails app that made coupons and made heavy use of gnu barcode, but I did simple shell command to interface to it.

Related

CPCL printing programming testing

I'm trying to test code that sends a printing message to an iMZ320 printer. The printer takes instructions in the CPCL programming language. I don't have access to a printer I can print to, but I need to check some changes I have made to the printer code are formatting correctly. Is there any way to do that to test the code is displaying correctly?
Unfortunately the answer is no. Without access to the printer you cannot preview the changes. Online tools like Labelary are only compatible with ZPL. In practice, I find that even when I'm generating code from a WYSIWYG tool like Zdesigner, I always need to test and fine tune on an actual printer.

Zebra 105SL (Plus) 2-way communications

I have written a printing application that works well. I can write files, update settings and do most all functionality from one console. But one aspect of the program has eluded me for quite a while: the ability to read the Zebra register/configuration values.
It would be good to periodically be able to read the values on the Zebra and compare them to default known good standards and to be able to reset them if necessary.
Currently, in order to see these values, I need to either use the built-in web page (networked printers only), print a report, or scroll through the printer interface. What I really need to is a method to be able to read these registers values and create a known good setup file.
Has anyone been able to find any SDK or trick to read these values using .NET (C# or vb.Net)?
The application is a windows desktop utility used on my shop floor and I communicate with the printers using either LPT and ethernet interfaces (as applicable).
I would recommend checking out the Zebra Link-OS SDK which has a lot of functionality when it comes to what you can do with Zebra printers. Specifically they have a section titled "Getting all printer settings and their configuration". However the code example they provide will not work unless your printer is a Link-OS enabled printer. If that happens to be the case then great! If not you can use the SGD class within the Zebra.SDK.Printer namespace to use Set-Get-Do commands to retrieve and change information. More information on SGD can be found in this ZPL manual under the SGD Printer Commands section.

best way for design and print barcode label from handheld (ce5/compact framework) to zebra mobile printer

What i want is
Design a label layout(barcode on it).
Scan the information by handheld and print the label directly from mobile printer linked with bluetooth.
want to know:
best way to implement this? see my preferences list below
1) free of charge
2) the API should have 2D barcode support
3) label layout can be designed by Drag-and-drop. The best is a visual studio control. so we do not need too much coding.
Hope someone has experience can share some to me, what cotrol? what liberary? Must use zebra specific printing language?
Kindly show a technique chain of the best(easy, free). Thank you all.
You should try and go with the Zebra SDK (for windows ce too). I assume there is no drag and drop GUI designer tool. But you may examine the code generated by a label designer application printing to a zebra printer using file: as output port.
Zebra provides good SDKs, samples and support. For example to print a QR code:
^XA^FO100,100^BQN,2,10^FDYourTextHere^FS^XZ
You see, it is more or less readable where to replace text to get another QR barcode.
see also https://km.zebra.com/kb/index?page=content&channel=SAMPLE_CODE
You may need to study the ZPL programmers guide and then you can start to print your own mind-designed labels. Printing meeans to send ZPL code lines directly to the printer.

Print to a UPS / Fedex Thermal printer?

I have a client asking if their web application (PHP) can easily print to a UPS / Fedex thermal label printer.
So for instance, I can get back a PDF from UPS/Fedex with the shipping label. I just need to print that.
Does anyone know if you can print directly to these printers or, if not, if there's another way to do it?
EDIT: To clarify, all I want to accomplish is to be able to print to these printers, without having to make my client ALT-TAB to some third-party application like UPS Worldship or ShipRush or QuickBooks Shipping Manager and clicking 'Print' within that application. Do-able?
Getting the labels in correct format
The FedEx & UPS APIs provide options to get thermal label specific types. You will beat your head on the keyboard trying to get PDFs to print properly on thermal printers.
Some common thermal types EPL/EPL2, ZPL/ZPLII. Most thermal printers will accept documents matching one of these types.
For Fedex something like this in your ShipRequest - This is using the FedEx WSDL for shipping.
RequestedShipment.LabelSpecification.ImageType = FedExShipService.LabelSpecificationImageType.ZPLII
And UPS - Building XML to post to the UPS service.
<LabelSpecification>
<LabelPrintMethod>
EPL2
</LabelPrintMethod>
</LabelSpecification>
Printing the labels
You will need to essentially send "raw" data to the printer. I started with this article and adopted it to my solution. FedEx for example returns a byte array which contains the label information - I convert this to a string and then send to the printer.
'Convert from Byte Array to String
Dim enc As System.Text.ASCIIEncoding = New System.Text.ASCIIEncoding()
Dim strConverter As String = enc.GetString(<ByteArrayFromFedEx>)
http://www.paulaspinall.com/post/2008/05/31/Sending-data-direct-to-a-printer.aspx
There is also another thread on SO about this topic.
Sending raw data to FedEx Label printer
I used to work on UPS shipping systems and yes you can print using the thermal printers. You need the correct drivers installed to do this. Depending how you want to print will also determine how you need to install the printer (local or shared printer). HTH
Your best source of information on how to print will come from the printer manufacturors web sites. I have referred to this article in the past when developing solutions for customers that consume the UPS API's.
Sending Raw EPL2 Directly to a Zebra LP2844 via C#".
This blog post goes into good detail about printing labels from code. Dn't be scared off because it has C# in it's title.
The manufacturers do an okay job of providing the information you need.
Shiprush has an api you can use to generate labels from code. It is pretty flexible, and can either send the label to a printer or return the label to your code for you to handle.
This open source applet would allow you to print from PHP. I personally stay away from Java but it may do the trick.
http://code.google.com/p/jzebra/
You will not be able to print the carrier PDF to the device, however you can take the raw EPL/ZPL code from the carrier and have that sent to the printer.
There is an ActiveX control from UPS that you can install. If you return the EPL stream with a MIME type of application/epl2 the ActiveX control will take the data and send it to the thermal printer.
Google "ups thermal activex"

Web-based printing solutions

I'm building a new web-based product. The problem is that many clients have specific printers to print specific documents. Just think reports,barcodes,invoices etc. All on a special printer with the right paper etc...
Usually when printing from the web you cannot make the software choose a printer or change the settings. However it's just that that I want to do.
I want to print without a dialog. And enter the printer + settings with my software
The only solution I know of now is the commercial version of acrobat that has some javascript printing support..
Does anyone know of any other alternatives ?
Thanks in advance !
small-medium business
No heavy installion but common stuff is ok
ie. flash/silverlight/acrobat/whatever is possible
I generate what is necessary for printing (PDF/Tiff etc)
Who are your customers -- enterprises or SOHO? Are you generating PDFs? Or, raw tiffs? If you are generating PDFs there is something called a JDF file where you can specify the print settings to your heart's content. The flip side is the device needs to be capable of understanding JDFs. You can then attach the JDF with the PDF as a mime package. If you are generating tiffs, I think there isn't much need of printer settings except for the correct device profile(s) to be installed.
Because of security reasons, you cannot control that from within the browser.
If I where in your shoes, I'd create a small program for my clients to install, registering a specific file extension to this program and creating files in this format on the website, and have the program do the printing for me.
Your easy choices are either PDF or Microsoft's Reporting/Report Viewer

Resources