Popup Print Script Error

I have a popup that I placed a button on it that has the following script:

job = system.print.createPrintJob(event.source.parent)
job = setShowPrintDialog(1)
job.print()

I would like this script to print the contents of my popup. Whenever I try to run this, I receive the following error

File "function:runAction", line 2, in runAction AttributeError: 'com.inductiveautomation.ignition.common.script.Imm' object has no attribute 'print'

I am not sure what this error means?

Thank you

You can’t use that in perspective, the scope of this function is only Vision -

https://docs.inductiveautomation.com/display/DOC80/system.print.createPrintJob

To add to what @bkarabinchak.psi said, there is currently no way to send a print job with perspective, that I am aware of.

Perspective clients are web browser sessions. Browsers don’t allow websites to push a print job.
Think of the fun that could be had by the black hats if that were possible.

You could consider having the button run the print job on the gateway and direct it to the local printer. There should be some posts on the forum detailing how to do that.

1 Like

Is this feature only for printing reports, or can it print an entire popup?

The function you’re attempting to use, as @bkarabinchak.psi has pointed out, is only available in a ‘Vision Client’. You have tagged this topic as perspective, and so we are assuming you are attempting to use this in a Perspective based application.

The function when used in a Vision Client can be used to print a Component.

The script you have provided will not work in a Perspective application. Not only is the system.print.createPrintJop() function not available, but neiter is event.source.parent.

On top of that, but the script as provided has an error, as you are overwriting the variable job with setShowPrintDialog(1) in the second line.

2 Likes

Your users will have to manually request to print a page or a selection from their browser’s menu. You cannot automate this–it is a browser security violation.

Yes, I understand that now. I was replying to @Transistor since he said that there was a way to print to the gateway.

As of now, is there any way to “print” a popup in perspective? Based on what I am seeing, it does not seem possible. If it is not possible, is there a way that I can save a popup, locally, as a PDF?

Thank you.

No, the closest you can get is to run a report via script and push a download of the report's PDF (via system.perspective.download). Your user would have to accept the download, open it, and print it.

2 Likes

I apologize, but maybe I should have been more clear. I have a popup that does not have the report viewer component. In a perfect world, the user would be able to click a button and the popup will print as a PDF and save to their local PC. Basically, doing a “print screen” function of just the popup that is opened. Based on what I am finding and what you have said, doing a print command is not possible…

I looked into the command system.perspective.download like you suggested, and I looked at the example of it, but I am not sure how/where I would call the popup to be downloaded in the script?

You cannot print your Perspective popup.

The closest thing you can do is create a report that contains the same data as your popup and trigger a download of that.

You cannot print your Perspective popup.

2 Likes