Check printer in ZPL mode (iOS & Android)

Hi

 

In your document "Best Practices in Creating a printing application for Zebra printers", it sates that the application should check the printer formatting language prior to printing - our application prints in ZPL, what does the code look like to do this in both iOS and Android?

 

As well, do you have any code to have your application load fonts on the printer?

 

Thanks!

Manuel Caicedo-...
Hi Shawn,We have developed

Hi Shawn,

We have developed several samples code in Android Studio that implemented Zebra’s best practices. Also, there is a blog that explains aspects regarding the importance of the selecting the proper printer language. I have added another link to a forum request which will help you with the font software question.

Most of the libraries in our LINK-OS SDK support similar classes in iOS and Android. Please, follow the links below where you can compare the structure of each API.

IOS-API Documentation

ZSDK_API: Zebra API

Android-API Documentation

Zebra API for Android (build v2.9.2275)

ZPL – Printing Language set up:

Android:

SGD.SET("device.languages", "zpl", connection);

or

SGD.SET("device.languages", "hybrid_xml_zpl", connection);

iOS:

[SGD SET:"device.languages" withValue:@"zpl" andWithPrinterConnection:zebraPrinterConnection error:&error];

or

[SGD SET:"device.languages" withValue:@"hybrid_xml_zpl" andWithPrinterConnection:zebraPrinterConnection error:&error];

Check Printing language:

Android:

String printerLanguage = SGD.GET("device.languages",connection);

iOS:

NSString *printerLanguage = [SGD GET:"device.languages" withPrinterConnection:zebraPrinterConnection error:&error];

Links to sample Code implementing Best practices in Printing Apps

https://km.zebra.com/kb/index?page=answers&type=search&searchid=1459976165817&newsearch=y&question_box=android+studio&restrict=

Blog

Forum Question

https://developer.zebra.com/message/84193#84193

Please, let us know if the information was useful and it answered your questions.

Thanks,

MC

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Shawn Rehill
wow - that is a thorough

wow - that is a thorough answer, thank you.  It looks like I have a ton of work ahead of me on this. 

One question - should I set the device language during app initialization, or during each print command?

Thanks

Shawn

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Manuel Caicedo-...
Hi Shawn,There are several

Hi Shawn,

There are several uses cases where you can decide when to add this check point step in your development logic.

1.) App Initialization

2.) When the user pairs the printer for first time with the app during his work shift.

3.) If the printer is working with different users, and there is a login change with a new user in the app. It is recommended to verify and set up ZPL before to send print jobs.

4.) If the mobile device is using different apps with the printer, and these are using different printer languages like CPCL, Line_print. It is recommended to verify and set up ZPL before to send print jobs

Regarding your font question, I forgot to mention that the link associated in my previous reply is when the printer is configured to work in CPCL or Line_Print.

For ZPL, the API includes classes and methods that allow you to do downloading and conversion of different ZPL fonts.

You can use the following class and interface located in the com.zebra.sdk.printer package. Please, review the links for the API documentation of my previous reply.

Class FontConverterZpl

Interface FontUtil

Thanks,

MC

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Yusuf Unlu
Hi, I was trying to make bold

Hi, I was trying to make bold characters and barcode. So I decided to change the mode to ZPL. but I couldnt

conn.open();

SGD.SET("device.languages", "zpl", conn);

ZebraPrinter zPrinterIns = ZebraPrinterFactory.getInstance(conn);

zPrinterIns.sendCommand("^FO350,50^AGR^FDwhatever,milk,butter,salt^FS");

Thread.sleep(500);

conn.close();

When I debugged it it say: SGD.GET("device.languages",conn) = "line_print"

Can u help me pls ?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments