public interface BarcodeUtil
package test.com.zebra.sdk.job.examples;
 
 import java.awt.Color;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
 import com.zebra.sdk.comm.Connection;
 import com.zebra.sdk.comm.ConnectionException;
 import com.zebra.sdk.comm.TcpConnection;
 import com.zebra.sdk.common.card.containers.GraphicsInfo;
 import com.zebra.sdk.common.card.containers.JobStatusInfo;
 import com.zebra.sdk.common.card.enumerations.CardSide;
 import com.zebra.sdk.common.card.enumerations.GraphicType;
 import com.zebra.sdk.common.card.enumerations.OrientationType;
 import com.zebra.sdk.common.card.enumerations.PrintType;
 import com.zebra.sdk.common.card.exceptions.ZebraCardException;
 import com.zebra.sdk.common.card.graphics.ZebraCardGraphics;
 import com.zebra.sdk.common.card.graphics.ZebraCardImage;
 import com.zebra.sdk.common.card.graphics.ZebraCardImageI;
 import com.zebra.sdk.common.card.graphics.ZebraGraphics;
 import com.zebra.sdk.common.card.graphics.barcode.CodeQRUtil;
 import com.zebra.sdk.common.card.graphics.barcode.ZebraBarcodeFactory;
 import com.zebra.sdk.common.card.graphics.barcode.enumerations.Rotation;
 import com.zebra.sdk.common.card.jobSettings.ZebraCardJobSettingNames;
 import com.zebra.sdk.common.card.printer.ZebraCardPrinter;
 import com.zebra.sdk.common.card.printer.ZebraCardPrinterFactory;
 import com.zebra.sdk.device.ZebraIllegalArgumentException;
 
 public class PrintBarcodeExample {
 
 	public static void main(String[] args) {
 		Connection connection = null;
 		ZebraCardPrinter zebraCardPrinter = null;
 		ZebraGraphics graphics = null;
 
 		try {
 			connection = new TcpConnection("1.2.3.4", 9100);
 			connection.open();
 
 			zebraCardPrinter = ZebraCardPrinterFactory.getInstance(connection);
 			if (zebraCardPrinter == null) {
 				return;
 			}
 
 			graphics = new ZebraCardGraphics(zebraCardPrinter);
 			graphics.initialize(0, 0, OrientationType.Landscape, PrintType.MonoK, Color.WHITE);
 
 			List<GraphicsInfo> graphicsData = new ArrayList<GraphicsInfo>();
 			drawBarcodeImage(graphics, graphicsData);
 
 			zebraCardPrinter.setJobSetting(ZebraCardJobSettingNames.K_OPTIMIZATION_FRONT, "Barcode");
 
 			int jobId = zebraCardPrinter.print(1, graphicsData);
 			boolean bSuccess = pollJobStatus(zebraCardPrinter, jobId);
 			if (!bSuccess) {
 				zebraCardPrinter.cancel(jobId);
 			}
 
 			JobStatusInfo jStatus = zebraCardPrinter.getJobStatus(jobId);
 			System.out.println("Job complete: " + jStatus.printStatus);
 		} catch (Exception e) {
 			e.printStackTrace();
 		} finally {
 			cleanUp(connection, zebraCardPrinter, graphics);
 		}
 	}
 
 	private static void drawBarcodeImage(ZebraGraphics graphics, List<GraphicsInfo> graphicsData) throws IOException {
 		CodeQRUtil barcodeUtil = ZebraBarcodeFactory.getQRCode(graphics);
 		barcodeUtil.drawBarcode("https://www.zebra.com", 50, 50, Rotation.ROTATE_0);
 
 		ZebraCardImageI image = graphics.createImage();
 		graphicsData.add(addBasicImage(CardSide.Front, PrintType.MonoK, 0, 0, -1, image.getImageData()));
 	}
 
 	private static GraphicsInfo addBasicImage(CardSide side, PrintType printType, int xOffset, int yOffset, int fillColor, byte[] imageData) {
 		GraphicsInfo graphicsInfo = new GraphicsInfo();
 		graphicsInfo.fillColor = fillColor;
 		graphicsInfo.graphicData = imageData != null ? new ZebraCardImage(imageData) : null;
 		graphicsInfo.graphicType = imageData != null ? GraphicType.BMP : GraphicType.NA;
 		graphicsInfo.opacity = 0;
 		graphicsInfo.overprint = false;
 		graphicsInfo.printType = printType;
 		graphicsInfo.side = side;
 		graphicsInfo.xOffset = xOffset;
 		graphicsInfo.yOffset = yOffset;
 		return graphicsInfo;
 	}
 
 	private static boolean pollJobStatus(ZebraCardPrinter device, int actionID) throws ConnectionException, ZebraCardException, ZebraIllegalArgumentException {
 		boolean success = false;
 		long dropDeadTime = System.currentTimeMillis() + 40000;
 		long pollInterval = 500;
 
 		// Poll job status
 		JobStatusInfo jStatus = null;
 
 		do {
 			jStatus = device.getJobStatus(actionID);
 			System.out.println(String.format("Job %d, Status:%s, Card Position:%s, " + "ReadyForNextJob:%s, Mag Status:%s, Contact Status:%s, Contactless Status:%s, Error Code:%d, Alarm Code:%d", actionID, jStatus.printStatus, jStatus.cardPosition, jStatus.readyForNextJob,
 					jStatus.magneticEncoding, jStatus.contactSmartCard, jStatus.contactlessSmartCard, jStatus.errorInfo.value, jStatus.alarmInfo.value));
 
 			if (jStatus.contactSmartCard.contains("station")) {
 				success = true;
 				break;
 			} else if (jStatus.contactlessSmartCard.contains("station")) {
 				success = true;
 				break;
 			} else if (jStatus.printStatus.contains("done_ok")) {
 				success = true;
 				break;
 			} else if (jStatus.printStatus.contains("alarm_handling")) {
 				System.out.println("Alarm Dectected: " + jStatus.alarmInfo.description);
 				success = false;
 			} else if (jStatus.printStatus.contains("error") || jStatus.printStatus.contains("cancelled")) {
 				success = false;
 				break;
 			}
 
 			if (System.currentTimeMillis() > dropDeadTime) {
 				success = false;
 				break;
 			}
 
 			try {
 				Thread.sleep(pollInterval);
 			} catch (InterruptedException e) {
 				e.printStackTrace();
 			}
 
 		} while (true);
 
 		return success;
 	}
 
 	private static void cleanUp(Connection connection, ZebraCardPrinter genericPrinter, ZebraGraphics graphics) {
 		if (graphics != null) {
 			graphics.close();
 			graphics = null;
 		}
 
 		try {
 			if (genericPrinter != null) {
 				genericPrinter.destroy();
 				genericPrinter = null;
 			}
 		} catch (ZebraCardException e) {
 			e.printStackTrace();
 		}
 
 		if (connection != null) {
 			try {
 				connection.close();
 				connection = null;
 			} catch (ConnectionException e) {
 				e.printStackTrace();
 			}
 		}
 	}
 }
 
| Modifier and Type | Method and Description | 
|---|---|
| void | doQuietZone(boolean value)Controls whether a quiet zone should be included or not. | 
| void | drawBarcode(String data,
           int x,
           int y,
           Rotation rotation)Draws the selected barcode symbology at the user specified x and y coordinates. | 
| double | getBarHeight()Returns the height of the bars. | 
| double | getBarWidth(int width)Returns the effective width of a bar with a given logical width. | 
| java.awt.Font | getFont()Returns the font of the human-readable portion. | 
| double | getHeight()Returns the full height of the barcode. | 
| double | getModuleWidth()Returns the width of the narrow module. | 
| String | getPattern()Returns the pattern to be applied over the human readable message. | 
| double | getQuietZoneWidth()Returns the width of the quiet zone. | 
| double | getVerticalQuietZone()Returns the vertical quiet zone. | 
| boolean | hasQuietZone()Indicates whether a quiet zone is included. | 
| void | setBarHeight(double height)Sets the height of the bars. | 
| void | setFont(java.awt.Font font)Sets the font of the human-readable portion. | 
| void | setHeight(double height)Sets the full height of the barcode including the human-readable portion. | 
| void | setMessagePosition(HumanReadablePlacement placement)Sets the placement of the human-readable part. | 
| void | setModuleWidth(double width)Sets the width of the narrow module. | 
| void | setPattern(String pattern)Sets the pattern to be applied over the human readable message. | 
| void | setQuietZoneWidth(double width)Sets the width of the quiet zone. | 
| void | setVerticalQuietZone(double height)Sets the height of the vertical quiet zone. | 
void drawBarcode(String data,
               int x,
               int y,
               Rotation rotation)
data - Data to encode.x - The x coordinate.y - The y coordinate.rotation - The orientation of the barcode.void doQuietZone(boolean value)
value - True to include a quite zone.void setBarHeight(double height)
height - The height of the bars (in pixels).void setFont(java.awt.Font font)
font - The font.void setHeight(double height)
height - The full height (in pixels).void setModuleWidth(double width)
width - The width of the narrow module (in pixels).void setMessagePosition(HumanReadablePlacement placement)
placement - The placement of the human-readable part.void setQuietZoneWidth(double width)
width - The width of the quiet zone (in pixels).void setVerticalQuietZone(double height)
height - The height of the vertical quiet zone (in pixels).double getBarHeight()
java.awt.Font getFont()
double getHeight()
double getModuleWidth()
double getQuietZoneWidth()
double getVerticalQuietZone()
void setPattern(String pattern)
pattern - The pattern to be applied over the human readable message.String getPattern()
boolean hasQuietZone()
double getBarWidth(int width)
width - The logical width (1=narrow, 2=wide).
				© 2016 ZIH Corp. All Rights Reserved.