en-USnl-NL

Getting started with WebToZebraPrint

The process of performing a printing job is best described by this flowchart. Each step will be explained under each paragraph.

 

1. CPCL or ZPL script

Printing to a Zebra mobile printer is all about interpreting an amount of CPCL/ZPL markup language which should be provided by your web application. Although explaining of the CPCL/ZPL markup language is not in the scope of this tutorial, al lot of online documentation is available. For the purpose of this tutorial we will use this snipped of CLCL script which will print ‘Hello World’.

U1 setvar "media.feed_length" "25"  //Set media feed
! 0 200 200 50 1  //Set start position cpcl scripting command
PREFEED 0  //Feed at start
SETFF 0 0  //Formfeed to 0
T 5 0 5 0 Hello World  //The actual text
FORM
POSTFEED 0  //Feed at end
PRINT  //Print command


2. Encoding the script

Once the Zebra script is available, the script must be encoded to a base64 encoded string. Like in C#: 

byte[] plainTextBytes = Encoding.GetEncoding(1252).GetBytes(cpclScript);
string encodeValue = Convert.ToBase64String(plainTextBytes);

3. Create link

Last step is to embed the encoded script into a link which will make the mobile device to open the webToZebraPrint app en parse the script to be printed. After the print is done, it will return to calling webpage. More detailed information is provided in the example project on the developer page.