RhoElements APD Printing

Anonymous (not verified) -
4 MIN READ

In a few weeks I'll go into detail about how to print using the RhoMobile suite to Zebra printers. Until then, I thought I would bring up printing with the RhoElements runtime and APD.  There is a good amount of documentation out there for this, but I thought I could add some updates and it occurred to me that a good basic example would be useful.

 

The RhoElements runtime comes with a basic printer driver built into the web-kit DOM.  This driver is called the Adaptive Print Driver(APD). As this driver is designed for printing, it is not bi-directional and can only send data.  You can specify the APD to use Bluetooth or a network connection. The APD handles everything else for the connection including Bluetooth pairing.

 

While we recommend using a communication method that is bi-directional, these methods require more effort on the part of the developer.  The benefit is being able to check status of the printer and make sure it is ready to print. If the printed output is a critical part of your app, please check out the documentation for Bluetooth here.  With networked printers you can create a websocket server to handle printing.  I may post another blog on that later.  Otherwise using the APD is fast and easy.

 

Definitely familiarize yourself with the APD documentation available.  I will just add some caveats and tips.  The documentation says to scan the Printer ID label on the printer, but most printers don't come with this label.  You can create one based on the Printer Type Codes reference, but this isn't necessary.  The documentation here doesn’t have the most recent Zebra printer models.  If you have a hard time finding your printer on the list no worries.  You can use any 3 character code that makes sense to you.  I usually use Z40 as the ID for my ZPL printers (QLn, GX, RP4T, etc.) I change to Z41 - Z49 for printers with differing print widths or ones that need different ZPL templates. For CPCL printers (RW, MZ, QL+, etc,) I start with C60.

 

The second step, as the documentation suggests, is to create your print job or label. The documentation recommends using a Zebra software tool named Label Vista, but this is an older product. We recommend to now use ZebraDesigner.  Follow the documentation in the product to create and test your printouts to make sure they look the way you want.  Export this label to a text file so you can manipulate it later.  If you plan to let users pick from multiple printers and print widths, you may need to create several files for each printer type.  You may also want to reference the programming manuals to create and manipulate files directly. 

 

There are three primary ways to print using the APD.  The techniques you use will vary depending on what you are trying to print and what printer(s) your users may be using.  I recommend using a blend of these techniques to fit your needs.

The first is to send the print data directly to the printer.  This can be useful if you know what type of printer your users will be using or if you want to print variable length receipts because you can manipulate the data at runtime. 

 

The second is to use stored formats.  Basically this means that you create a label with positioning and font information and send it to the printer to be saved with variable fields.  You then fill in those fields when you want to print. This can be very useful if you want to reduce the amount of data you send to the printers.  This is also the best way to send image files to the printer. 

 

The third way is to use templates.  These are explained in the APD documentation.  They are useful if you want to give your users plenty of options on what printer to use. 

 

The attached demo shows a blend of techniques used to create a line busting customer receipt.  For size sake, I'm only putting in the code for a ZPL printer (I'm testing with a QLn220).  If you want to test it yourself, put the LOGO.Z40 file in the APD/Formats folder and the CUST.Z40 file in the APD/Template folder.  Printing will happen in three steps.  The logo will be pre-saved onto the printer as a format. Some header information will be populated with a template.  Lastly the items will be printed one line at a time directly.

 

Please let me know if you find this demo helpful and what type of content you would like to see in the future.

Robin West

  www.zebra.com\ISV

profile

Anonymous (not verified)

Dfghjkjjn

Please register or login to post a reply

Replies