# Printing report with a button

**URL:** <https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021>\
**Category:** Ignition\
**Created:** [June 16, 2011, 9:24pm UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021 "2011-06-16T21:24:43Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![lcs226](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lcs226](https://forum.inductiveautomation.com/u/lcs226)\
**Post date:** [June 16, 2011, 9:24pm UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/1 "2011-06-16T21:24:43Z")

</div>

Hello All;

As a new user to Ignition, I am still trying to wrap my head around things. I am trying to print a report with the use of a button on the screen. I found that a right click over the report will allow you to print the report, I want to duplicate that function but with a button.

Thanks, Chris

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [June 16, 2011, 10:08pm UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/2 "2011-06-16T22:08:32Z")

</div>

Right just put the following script in the actionPerformed event of the button:`report = event.source.parent.getComponent("Report Viewer")
report.print()`Of course replace the “Report Viewer” with the name of your report. Note: You may also have to change the path depending on where your report is compared to the button.

---

<div class="post-metadata">

**Author:** ![lcs226](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lcs226](https://forum.inductiveautomation.com/u/lcs226)\
**Post date:** [June 16, 2011, 11:06pm UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/3 "2011-06-16T23:06:32Z")

</div>

Thanks Travis,

What if I want to do it with the script module similar to your demo of a screen print?

Chris

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [June 17, 2011, 1:19am UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/4 "2011-06-17T01:19:50Z")

</div>

You can take a look at the system.print scripting functions:

[http://www.inductiveautomation.com/support/usermanuals/ignition/system\_print\_createimage.htm](http://www.inductiveautomation.com/support/usermanuals/ignition/system_print_createimage.htm)

Here is an example that will print the root container of the window:`rc = system.gui.getParentWindow(event).getRootContainer()
job = system.print.createPrintJob(rc)
job.setMargins(0.5)
job.showPageFormat = 0
job.orientation = orientation
job.print()
`

---

<div class="post-metadata">

**Author:** ![MadMax](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@MadMax](https://forum.inductiveautomation.com/u/MadMax)\
**Post date:** [July 26, 2011, 12:38am UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/5 "2011-07-26T00:38:22Z")

</div>

[quote=“Travis.Cox”]Right just put the following script in the actionPerformed event of the button:`report = event.source.parent.getComponent("Report Viewer")
report.print()`Of course replace the “Report Viewer” with the name of your report. Note: You may also have to change the path depending on where your report is compared to the button.[/quote]

Are there also methods for the “Save as PDF/ HTML/PNG”? If so, how do you automate so no human intervention is needed, like to launch reports from a timer script?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [July 26, 2011, 5:37pm UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/6 "2011-07-26T17:37:18Z")

</div>

To save a report as a PDF with no human intervention, you’d do something like this:

`report = event.source.parent.getComponent("Report")
bytes = report.getBytesPDF()
filename = "C:\\reports\\myreport.pdf"
system.file.writeFile(filename, bytes)`

---

<div class="post-metadata">

**Author:** ![EricFrancoeur](https://avatars.discourse-cdn.com/v4/letter/e/dfb087/32.png) [@EricFrancoeur](https://forum.inductiveautomation.com/u/EricFrancoeur)\
**Post date:** [July 30, 2014, 11:10am UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/7 "2014-07-30T11:10:31Z")

</div>

A little off topic here…

How can I see all the functions associated to a report, like the .print() and .getPDFBytes I think is another one

I want to know if there’s an .open one or something like that

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [July 30, 2014, 12:22pm UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/8 "2014-07-30T12:22:02Z")

</div>

The simplest way is to check the Ignition User Manual: [inductiveautomation.com/support … viewer.htm](https://inductiveautomation.com/support/usermanuals/ignition/index.html?reporting_components_reportviewer.htm)

You could also run code like this from a button, but this finds all the methods and properties:

```auto
report = event.source.parent.getComponent("Report Viewer")
print dir(report)
```

The result will be printed to the Output Console.

---

<div class="post-metadata">

**Author:** ![anna](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@anna](https://forum.inductiveautomation.com/u/anna)\
**Post date:** [August 13, 2014, 10:02pm UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/9 "2014-08-13T22:02:05Z")

</div>

Just a little note on what nmudge suggested - not all (in fact, just a small fraction) of what dir() will return is readily usable or useful, and there will be no accompanying documentation.

You may want to search the User Manual by key word instead. There is a whole section on Reporting (the first page is here: [https://www.inductiveautomation.com/support/usermanuals/ignition/index.html?reporting\_introduction\_overview.htm](https://www.inductiveautomation.com/support/usermanuals/ignition/index.html?reporting_introduction_overview.htm)); there is also Appendix C for Scripting functions (check out system.print section)

---

<div class="post-metadata">

**Author:** ![psirikonda3](https://avatars.discourse-cdn.com/v4/letter/p/a587f6/32.png) [@psirikonda3](https://forum.inductiveautomation.com/u/psirikonda3)\
**Post date:** [February 22, 2018, 1:55pm UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/10 "2018-02-22T13:55:47Z")

</div>

> [@nmudge](#):
>
> print dir(report)

I copied and gave my report name but i am getting error out as follows in console

File "event:actionPerformed", line 2, in   
TypeError: print(): expected 1 args; got 0

---

<div class="post-metadata">

**Author:** ![psirikonda3](https://avatars.discourse-cdn.com/v4/letter/p/a587f6/32.png) [@psirikonda3](https://forum.inductiveautomation.com/u/psirikonda3)\
**Post date:** [February 22, 2018, 1:58pm UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/11 "2018-02-22T13:58:15Z")

</div>

My requirement is to print the report by clicking the button componet, I have used report module to design the report. I am doing scripting to perform this action in actionPerformed event handlers.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [February 22, 2018, 3:03pm UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/12 "2018-02-22T15:03:14Z")

</div>

Use system.report.executeAndDistribute()

[https://docs.inductiveautomation.com/display/DOC79/system.report.executeAndDistribute](https://docs.inductiveautomation.com/display/DOC79/system.report.executeAndDistribute)

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [October 25, 2021, 11:50am UTC](https://forum.inductiveautomation.com/t/printing-report-with-a-button/3021/13 "2021-10-25T11:50:21Z")

</div>

Is it possible to set the printer size by standards ? For example, I set the printer properties to be width and size for A4 but when the printer dialog opens up, it automatically selects Letter instead of A4.

Thanks,
