getPrinterNames() not showing all printers

I've added a few printers to a gateway VM through various methods (directly through TCP/IP, network printer wizard, etc). When I call system.print.getPrinterNames() only the Microsoft XPS Document Writer and Microsoft Print to PDF printers show up. However, if I call system.print.getDefaultPrinterName() then I can get the default printer.

I can change the default printer in the VM and it changes for getDefaultPrinterName but the added printers never show up in getPrinterNames. I've tried restarting the print spooler service with no luck.

I'm sure I'm missing something obvious.

Where are you calling this from?

I have it on a perspective that calls it from a script library so it should be running from the Gateway?

def getPrinterNames():
	printers = system.print.getPrinterNames()
	return printers
	
def getDefaultPrinter():
	printer = system.print.getDefaultPrinterName()
	return printer

If it runs on the gateway then it's running as whatever service user Ignition is running as, which I'm guessing has something or everything to do with your problem.

See system.print.getDefaultPrinterName() returns null - #9 by michael.flagler also

I logged into the VM as the service account and added the printers from there. I am also setting the default printer from the service account. Why would getDefaultName show the default printer as I'm changing it and the full list of printers not show up in getPrinterNames?

No idea. Windows stuff :confused:

2 Likes

A running java instance does not always grab newly installed printers that were installed while the runtime is up on windows.

An Ignition gateway service restart will allow those printers to be seen.

3 Likes

Thanks, I have an after-hours gateway restart scheduled. I'll update with the outcome.

Restarting the gateway service did the trick. Now all added printers are showing by calling system.print.getPrinterNames()

1 Like