System.Report.executeandDistribute()

Hi to all,
I’m trying to print a report using script, here the code:

if system.tag.read("PLC_MetalCan/PalletPresente").value == 1:
    system.report.executeAndDistribute(path = 'EtichettaPallet' , 
    project = 'PLC_MetalCan' ,
    action = 'print' , 
    actionSettings = {"primaryPrinterName":"Markem-Imaje 2630 (300 dpi)","copies":1 })

All seems fine but the page printed is all White.
do you know where’s the mistake?

thank’s in advance for all the replies.

Printing issues are often a bit challenging to troubleshoot. I don’t see anything obviously wrong with your setup, but I almost never print reports. :slight_smile:

Does your report print okay when you test it in the Schedule panel in the reporting workspace? Does it save okay if you change the distribute action to ‘save’ and give it a path/filename relative to the gateway?

Is there anything in the gateway logs? Try turning the reporting.Data log to debug to get the most info.

Hi,
we create a label with the report.
If i create PDF with this script :

settings = {"path":"C:\\", "fileName":"Report.pdf", "format":"pdf"}
system.report.executeAndDistribute(path="EtichettaPallet", project="PLC_MetalCan", action="save", actionSettings=settings)

and it’s perfect.

If i use this script and send directly to the printer :

system.report.executeAndDistribute(path = 'EtichettaPallet' , 
    project = 'PLC_MetalCan' ,
    action = 'print' , 
    actionSettings = {"primaryPrinterName":"Markem-Imaje 2630 (300 dpi)","copies":1 })

i see a job in the queue but print a white label?
Is the problem that is not processed from the printer driver ? There’s another system for print directly ?

BR

Without turning your logs to trace, it’s going to be hard for you to debug further. Your best bet is to contact support and have them help you with this.

@KathyApplebaum I’m trying to troubleshoot a System.Report.executeandDistribute() issues. Where can I find the logs you’re talking about?

Thanks,
MMurphy

It’s going to depend on where you think the problem might be, but I’d start with reporting.Scripting. If that doesn’t do it, try turning all of reporting to trace and use the MDC keys for your report name and your project name to find the log statements for that report.

I was able to find the logs. My issue was caused by Ignition changing the string I was using for the path to where I wanted the report saved.

I was running something like the script below.

The leading backwards slash was being dropped by Ignition. Log screenshot below.

Is this expected behavior? I tried making a string tag of " \ " within the script and it didn’t like that either.

M Murphy

EDIT: To be clear, my path had two slashes in the script but by the time it hit the log it only had one.

That’s a Python (and many other languages) thing, to clarify, not an Ignition thing - backslashes are a common ‘escape’ character, so if you need to represent a literal newline, say, in a string, you use "\n", since there’s no “character” that can represent a newline. The escape character for the backslash itself is…two back slashes - so "\\" is actually defining a single character \ in the output. You can prefix the Python string literal with r to make it “raw”, meaning it won’t process escape characters:
sPath = r"\\vmware-host\Shared Folders\etc"
Or, you can “double” the escape characters to make the same output string:
sPath = "\\\\vmware-host\\Shared Folders\\etc"

2 Likes

Awesome. Thanks @PGriffith!