Search code examples
javaprintingzpl

Sending SGD command to Zebra printer and receiving the response with Java


I'm working on Java application which prints label on Zebra printer. I've been using ZPL language and Java printing API till now, but ZPL is not suffiecient for my further works. The next thing I need to do is (programatically) checking if font with specified name is already installed on the printer. I've found that I may achieve my goal with SGD commands. But I have no idea how to send it from Java application and get the response. The command I would like to send is

! U1 do "file.dir" "R:"

Has anybody met similar problem? The printer is connected with computer via USB. Is it possible to use Java printing API to send the command and receive answer or maybe I should use sockets or something completely different?


Solution

  • SGDs like that need to be terminated with a \r\n.

    Also, Zebra provides a Java API to ease communications with Zebra printers. There's a bunch of Javadoc and example code that comes with the download