My printer Zebra TTP 7030 is connected to local computer via USB.
I can print data using javax.print API but I cant get printer status or any data from printer.
I tried to get printer status from Java printService attributes but It does not return any valuable information about printer real time status.
Class<? extends Attribute>[] supportedAttributeCategories = (Class<? extends Attribute>[]) service.getSupportedAttributeCategories();
for (Class<? extends Attribute> category : supportedAttributeCategories) {
DocFlavor[] flavors = service.getSupportedDocFlavors();
for (DocFlavor flavo : flavors) {
Object supportedAttributeValues = service.getSupportedAttributeValues(category, flavo, service.getAttributes());
if (supportedAttributeValues instanceof Attribute) {
Attribute attr = (Attribute) supportedAttributeValues;
attribSet.add(attr);
} else if (supportedAttributeValues != null) {
Attribute[] attrs = (Attribute[]) supportedAttributeValues;
for (Attribute attr : attrs) {
attribSet.add(attr);
}
}
}
}
for (Attribute attr : attribSet) {
System.out.println(attr.getName());
System.out.println(service.getDefaultAttributeValue(attr.getCategory()));
}
Zebra's Link OS SDK does not support my printer. Is there a way to get printer status?
SOLUTION: I used JNA to get Windows printer status for my zebra printer.
Here is example how to get printer information using JNA How can i get a printer's make and model in Java?