Printing From Perspective

Hi there,

I am wondering what is the correct way to print a report using a button in perspective I thought it was this but that doesn't seem to do anything or throw me any errors:

	system.report.executeAndDistribute(
	    path="LotPackagingLabel",
	    project="MES_App",
	    action="print",
	    actionSettings={"primaryPrinterName": "Canon TS3100 series"}
	)

Does the Ignition service running in the gateway have that printer name defined? (Distinct from printers associated with a user logged into that server's desktop.)

no this printer is just locally on my computer. Does it need to be on the actual gateway to print?

From .executeAndDistribute(), yes. A Report Viewer or PDF Viewer under the browser users' control is needed to print locally.

Vision can script control of a local printer.

Oh I see but to do a local test before running it directly to a network printer on the server I would need to use the report viewer?

A report viewer, or a PDF viewer in the browser, can print to local printers at the browser location. The gateway, whether scripted .reportAndDistribute(), or any other automated printing from gateway scope, can only use the printers pre-configured for the user the gateway runs as.

Sorry to revive this but how do you determine if the printer name is defined in Ignition

Probably this:
PrinterJob.lookupPrintServices()

Each item in the result will have a .name attribute.

system.print.getPrinterNames() works in all scopes for precisely this reason.

2 Likes

Ok I see the name there and it matches what I have but still not getting anything. No errors in the logs either. I press the button and nothing happens. I have also tried a test print without using Ignition and it works so I know the printer is working:

	system.report.executeAndDistribute(
	    path="LotPackagingLabel",
	    project="MES_App",
	    action="print",
	    actionSettings={"primaryPrinterName": "ZDesigner ZT510-203dpi ZPL"}
	)

This is happening on a button press

Why would you think that is a valid test? If you get no names in gateway scope, then the gateway user account has no printers defined.

(Testing in the designer script console tests the printers for the desktop user logged in, not printers for any other user account.)

I tried the test print to rule out if the printer drivers might have been messed up. If testing in the script console is not the way either where should I try and make sure this printer is accessible by Ignition service?

Ran the system.print.getPrinterNames() this was the result:

Which shows the printer in there. This is directly on the Ignition gateway

Took another look forgot to mention that my Ignition is running off a service. Would that explain why the print command isn't making it to the printer?