Printing Button in Perspective Project

Hello,
I am creating a QR code using Reports and monitoring it through a ReportViewer in a Perspective session. I need to print out the QR code using one button that opens the printer dialog.
I tried using the system.print method in the manual but it did not work and showed me this error:

com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
File “function:runAction”, line 2, in runAction
AttributeError: ‘com.inductiveautomation.ignition.common.script.Imm’ object has no attribute ‘print’

caused by org.python.core.PyException

Traceback (most recent call last):
File “function:runAction”, line 2, in runAction
AttributeError: ‘com.inductiveautomation.ignition.common.script.Imm’ object has no attribute ‘print’

Ignition v8.1.2 (b2021020311)
Java: Azul Systems, Inc. 11.0.9

system.print only works in Vision, not Perspective. Once the report file is open, the user needs to print the file just like anything else from the browser.

Thank you

Hi Bro @kghali. May I know that do you able to do the function you mentioned above which the user is able to print the particular screen when they click the print button. If YES, may I know that how do you write the script ?

Thanks in advance.

Hi @tohhy-pm17,

I am generating the report, then using webdev I’m executing that report (system.report.executeReport), then on perspective I created a button that calls the webdev and opens up the report which is a pdf file, then from the opened pdf I’m printing out.
Use this in the webdev:
bytesArray = system.report.executeReport(path=“my report”, project=“my project”, parameters=overrides, fileType=“pdf”)
return {‘contentType’:‘application/pdf’,‘bytes’:bytesArray}

This was my first project on Ignition with no experience and thinking of it right now, there could be other simpler ways to deliver the same results such as using the pdf viewer on perspective and the scheduling tool in reports if needed.

Good luck!

Thanks @kghali