Zebra Adaptive Printer Driver (APD) is a small executable program that runs on Zebra Mobile Computers. It provides a simple, yet powerful, interface to software applications, to transfer data from the user’s software application to virtually any portable printer, via cable, or Bluetooth, short-range RF, or WLAN wireless connections.
APD takes care of connectivity. APD takes care of different printer command languages. This means your application doesn’t need to know what type of printer is being used, or how it is connected. You application only has to decide what to print, and to which printer.
APD can print receipts, labels, tags, tickets, whatever the printer can print.
APD can use virtually any portable printer, and many desktop and industrial printers. Here’s some that we have tried: Zebra (includes Comtec and Eltron printers), O'Neil, Paxar-Monarch, Toshiba-TEC, Brother, Citizen Business Machines, Citizen Watch Co, Cognitive, Extech, Printronix, Sato, Seiko, S'Print.
Scan the label on the printer: this tells the APD all it needs to know about the printer.
In this example, the printer type and language, connection type, and TCP port number is taken from the PRINTER ID bar code, and the IP address is taken from the IP Address bar code.
The APD encodes the data into the relevant printer command language, opens connection to printer, sends data, and closes the connection.
The printer accepts the combined set of data and commands, adds data from its own memory (such as a logo) if required, and prints the required item.
To get the full functionality of APD, you will probably require a template file. This is normally a simple text file, stored in the terminal’s memory, that APD uses as a guide to format the data.
However, in some cases, not even this is required. APD has a built-in set of rules for the most popular printers (Zebra, Paxar, Toshiba-TEC etc.) to format data without a template file.
Also, if the data from the application is already formatted, APD needs nothing else.
The header and footer of our receipt can be designed using Zebra’s “Label Vista” design software for Windows PCs, as shown below.
This software allows the user to place text, barcode, and graphic fields onto a working area (the dotted area) and to select such parameters as font style, font size, line width, etc., as well as the position of each field.
Using the “Save” option, Label Vista converts the on-screen information to a set of commands that are saved in a simple text file.
Alternatively, you can work directly from the CPCL Programmers Manual and produce the set of commands directly using a text editor such as Notepad.
Either way, the command set will be very similar.
Note however, that Label Vista (or any other design software) can only approximate to what the printer actually produces. For example, in the example screen, “Al’s Restaurant” is not displayed in the correct script-like font.
The CPCL commands for the header section are shown below.
! 0 200 200 250 1 JOURNAL COUNTRY CP850 LEFT PCX 20 0 !<AlsLogo.pcx TEXT 1 0 50 100 Al's Restaurant TEXT 5 0 0 160 Date: 02/03/2004 Table: 14 TEXT 5 0 0 190 Your waiter today: Alphonso LINE 0 230 350 230 3 POSTFEED 0 PRINT
A few things to note about this:
The CPCL commands for the footer section, shown below, are similar to those in the header.
! 0 200 200 300 1 LEFT LINE 0 0 350 0 3 TEXT 4 0 20 20 TOTAL: oe 45.75 TEXT 5 0 70 70 Includes oe 6.87 VAT TEXT 1 0 100 110 Thank you. TEXT 5 0 10 160 We hope to see you again soon! B 39 2 1 50 20 200 45.75 POSTFEED 80 PRINT
Note: For full details of these commands refer to the Zebra CPCL Programmers Manual.
The line printer section is shown below.
! U1 SETLP 7 0 20 1 Chicken Soup œ 2.50 1 Melon + Parma œ 3.00 1 Beef Stroganoff œ 12.50 1 Lasagne œ 10.50 2 Green Salad œ 4.50 1 Banana Delight œ 3.25 1 Tiramisu œ 3.50 2 Coffee œ 4.00 1 Liqueur œ 2.00
Note: For full details of line printer mode, please refer to the Zebra CPCL Programmers Manual.
The complete data file to print our receipt on the Zebra Cameo 2 printer is shown below.
However, there is one major problem: This will always print exactly the same receipt! So we need to define which parts of the receipt need to change for each new receipt printed, and which can stay the same. In the text above, all the variable data has been highlighted in red.
So now, we can produce a template file which is the same as the text shown left, except that all the red text is replaced by markers to indicate the points at which new variable data is to be inserted by the application.
Using the Zebra Adaptive Printer Driver, the template is external to the application. For the application programmer, this means that:
The box below shows the contents of the template file used to generate the above label using a Zebra QL220 portable printer.
The markers (e.g. $$$$) shown in red tell the APD where to insert the data from the user application (shown below). The rest of the information, in black, comprises commands that the printer requires to set out the label.
The template used by the Zebra Adaptive Printer Driver to print our receipt on the Zebra printer is shown below.
The “date” variable is inserted at the position indicated by marker $$$$. “Table number” is inserted at $$$$.
Now that all the CPCL-specific commands and static data have been removed to the template file, the application software only needs to produce the variable data, as shown below.
$$[CMD:0101,1]$$ TR2 02/03/2004 14 Alphonso 45.75 6.87 1 Chicken Soup œ 2.50 1 Melon + Parma œ 3.00 1 Beef Stroganoff œ 12.50 1 Lasagne œ 10.50 2 Green Salad œ 4.50 1 Banana Delight œ 3.25 1 Tiramisu œ 3.50 2 Coffee œ 4.00 1 Liqueur œ 2.00
Note: A full explanation of this process is given in the APD Programmer’s Manual.
Now, let’s run the same application with an O'Neil 2T printer. Like the Zebra Cameo, this is a compact, portable printer, ideally suited to the task of printing receipts at the point of transaction. However, to use this printer, we need to code the data into O'Neil’s “EZ Print” command language. If our application had been written with the “CPCL” commands within the application, changing to “EZ Print” would have required a substantial change to the application code. But, as we have extracted all the “CPCL” code into a template file, all that is needed to work with the O'Neil printer is a new template file.
Again, for the simplicity of this example, O'Neil’s standard in-built fonts will be used. As these are not the same fonts as Zebra’s, some of the text will look slightly different. If an exact match were required, appropriate new fonts could be downloaded to the printer. However, as with the Zebra Cameo, the “AlsLogo.pcx” file needs to be downloaded to the printer so it can print the logo.
As with the Zebra Cameo, The O'Neil 2T has a line printer mode. However, not all printers offer this facility and there may be other reasons for not using line printer mode. So, to illustrate the point, we will generate two templates for this printer: the first using line printer mode, and the second using “EZ Print” for the entire receipt.
Following a similar process to that used for the Zebra printer, with “EZ Print” used for the header and footer sections and line printer mode for the central section, we can generate the complete print file shown below.
Following the same process as used for the Zebra Cameo printer, all the red sections on the previous page have been replaced by the appropriate markers to give the template shown below.
Exactly the same application data can be used with this template as was used with the template for the Zebra Cameo printer. In this case, the template will be called “TR2.N21”. The first part (TR2) is the same as before, as it relates to the same data; but the second part has been changed from “C22” to “N21” to show that it relates to an O'Neil 2T printer, rather than a Zebra Cameo 2.
The Adaptive Printer Driver will automatically select the appropriate version of “TR2” to suit the printer in use.
Although the template shown on the previous section will produce a perfectly good receipt, there is a slight issue with the central section. Because the standard O'Neil font used is narrower than that of the Zebra printer, there is a gap to the right of the price column.
To improve the appearance of the receipt, the text can be centralized on the receipt. A simple way to do this is to insert spaces to the left of the text by changing:
Alternatively, “EZ Print” can be used for the whole receipt. Strictly this isn’t necessary here, but “EZ Print” and has been implemented in the example, left, to demonstrate how it can be done. This process would also apply to printers that don’t offer a line printer option.
The above template uses a different central section to the one on the previous page:
The previous pages show how the Zebra Adaptive Printer Driver makes use of template files to remove the need for application programs to deal with printer-specific command languages, and to allow the application to work with different types of printer without needing changes to the application program code.
Examples of templates for two popular printers were shown. Both of these printers offer a line printer mode, as well as a PCL (printer command language) mode, and the templates use both PCL mode and line printer mode. However, it is also possible to produce templates for printers that only offer a PCL mode, or only offer a line printer mode (the latter option assumes that the printer can print graphics and barcodes).
Zebra Moto, Zebra Technologies and the Stylized M Logo are trademarks or registered trademarks of Zebra Trademark Holdings, LLC and are used under license. All other trademarks are the property of their respective owners. ©2011 Zebra Technologies, Inc. All Rights Reserved.