Button - print different component

I would like to print a component from another component. Does anyone know if there is a way to request print action of a different component? Specifically, in the onActionPerformed event of a button. I know I can request print action for the page / view / button.

Does system.print.createPrintJob work in perspective? https://docs.inductiveautomation.com/display/DOC81/system.print.createPrintJob

No, that is a Java Swing operation.

Is it possible to trigger a request print action of componentA from an event of componentB (perspective) ?

The documentation suggests not.

https://docs.inductiveautomation.com/display/DOC81/Component+Events+and+Actions#ComponentEventsandActions-RequestPrintAction

Interesting...would be nice.

You should make a feature request.

1 Like

Sounds like a good idea.

If anybody else wants this feature - Feature Request

1 Like

What if you create a message handler that you call from the button click, but the message would live on the component you want to print? I think that should work but I never tested this setup before.

I will try it out and reply back.

There is no scripting equivalent of the request print action. It has to be user-initiated. So a message handler cannot fire it.

This is absolutely possible, though the script editor doesn't provide the hinting that you can do it.

self.getSibling("SiblingNameHere").requestPrint("component", "FileName")
9 Likes

Cool! And no message handler needed for the simple case. TIL.

Can a pointer to this be added to the documentation for the action?

Documentation can be found here, though we were literally looking at this very documentation last week because it doesn't meet our (my) standards and there is an internal ticket open to improve the example.

Looking at the documentation for the analogous Action gives you a better idea of how to use the Scripting function.

2 Likes

Right, I linked the Action doc above. But it didn't have any indication/link to the corresponding component method. Nor does the component method doc link to the action. :man_shrugging:

1 Like

Right ! Thanks @cmallonee

1 Like