Using Scripting on a Button to Print a Report

Hello, I am trying to use a print button to print out a report. I have a Report Viewer on the page with the print button and am trying to print to a computer on the client side. Here is what I have right now:

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

The problem here, is that this ends up printing the entire page that the Report Viewer is on. It’s also printing the page at about 1in tall by 1/2in wide.

I know part of my problem lies in the “(event.source.parent)” part of the script. This points it to the page itself and not the Report Viewer. Is there a way to narrow the scope to just the Report Viewer? Any help would be greatly appreciated. Thanks in advance.

The event.source.parent portion is getting the container that the Report Viewer is placed in. If you wanted just the Report Viewer, you would need to get a reference to it: event.source.parent.getComponent('Report Viewer')

Alternatively, the Report Viewer does have its own built-in scripting functions, including a print function, so you could replace your code with:
event.source.parent.getComponent('Report Viewer').print()

Thank you. That’s exactly what I needed.