Get status of printer from Java?

Does anyone have a good methodology for getting the status of a network printer and making it available to ignition. Through scripting. is it available through system properties? Or maybe making an HTTP call?

Basically, I want to set a tag off or on. Based on whether a print can be reached or not. Talking to TSC label printers for what it matters.

Printers are notoriously tricky things. You could try pinging it but that would only tell you if it’s alive in the most basic sense, not that its necessarily functional or accepting print jobs, in the middle of a printer job or facing some error.

Some newer printers I’ve seen now accept basic HTTP requests so perhaps you could find some help there and probably your best option if available.

Some others host a little website at their IP address where they have the Status available and you could probably hardcode something to get that status via a script when asked.

As for making the printer “available” to Ignition, as long as the printer is available to the gateway OS it should be available to Ignition (I am assuming you are using the report module here). Making the printer available/usable by Ignition is not something I know of that can be set up via a script, you would have to configure that outside Ignition.

Inside of Ignition best you can hope for is 1) Seeing that the printer is not dead with a ping and 2) Possibly see the status of the printer with a HTTP call or by webscraping the printer webpage.

1 Like

In scripting if a printer wasn’t available I was going to default to the printer beside it. With some kind of logic.

I have like 15 of these printers.

The reports print automatically after some stuff happens in the field on the machines.

So I was going to send a prompt to the HMI and then just default the print job else where.

I figured I was going to probably have to scrape the printers web page or find the right call to make. If there wasn’t some better way to get status out of java or something.


I played around with javax.print, but it gives me ‘accepting-jobs’, regardless if the printer is online or not. :man_shrugging:

from javax.print import PrintServiceLookup
from javax.print import DocFlavor
from javax.print.attribute import HashPrintRequestAttributeSet
from javax.print.attribute.standard import MediaSizeName

aset = HashPrintRequestAttributeSet()
printServices = PrintServiceLookup.lookupPrintServices(None, aset)

for printService in printServices:
	attributes = printService.getAttributes().toArray()
array(javax.print.attribute.Attribute, [OneNote for Windows 10, accepting-jobs, supported, 0])
array(javax.print.attribute.Attribute, [Microsoft XPS Document Writer, accepting-jobs, supported, 0])
array(javax.print.attribute.Attribute, [Microsoft Print to PDF, accepting-jobs, supported, 0])
array(javax.print.attribute.Attribute, [HP8600 (HP Officejet Pro 8600), accepting-jobs, supported, 0])
array(javax.print.attribute.Attribute, [HP Officejet Pro 8600, accepting-jobs, supported, 0])
array(javax.print.attribute.Attribute, [HCIW, accepting-jobs, supported, 0])
array(javax.print.attribute.Attribute, [HCH-Copy, accepting-jobs, supported, 0])
array(javax.print.attribute.Attribute, [Fax, accepting-jobs, not-supported, 0])
1 Like

Interesting. Thank you.

They have a sdk docs and a JAR. I wonder what i would take to make it useable.

String status = TscEthernetDll.printerstatus(); 

its for android tho.

I just found it looking for a way to do it over http

1 Like

It looks the SDK is just sending extremely simple TCP messages - it should be pretty easy to decode via tool like Wireshark.

1 Like