# Printing report viewer

**URL:** <https://forum.inductiveautomation.com/t/printing-report-viewer/68276>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [January 5, 2023, 7:22pm UTC](https://forum.inductiveautomation.com/t/printing-report-viewer/68276 "2023-01-05T19:22:32Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esmeralda\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Esmeralda\_Lopez](https://forum.inductiveautomation.com/u/Esmeralda_Lopez)\
**Post date:** [January 5, 2023, 7:22pm UTC](https://forum.inductiveautomation.com/t/printing-report-viewer/68276/1 "2023-01-05T19:22:32Z")

</div>

Hello everyone, I need to print a report viewer that is located only here:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/1/d15a2b6d2aabff180007ea78d1dd18839fe47fc7.png)

I am not using the component inside a window part of the project, I just need to call the report and print it by a button and I have this code:

```auto

rv=event.source.parent.getComponent('ejemplo')
rv.print()

```

Thank you so much for your help.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 5, 2023, 7:36pm UTC](https://forum.inductiveautomation.com/t/printing-report-viewer/68276/2 "2023-01-05T19:36:27Z")

</div>

> [@Esmeralda\_Lopez](#):
>
> `event.source.parent.getComponent('ejemplo')`

That would get a reference to a component in the window with the button. `ejemplo` is a report, not a component. You will need to execute the report using one of the `system.report.execute*` functions. If the printer is reachable from the gateway, consider using `system.report.executeAndDistribute()` to send the print job directly to the printer.

---

<div class="post-metadata">

**Author:** ![Esmeralda\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Esmeralda\_Lopez](https://forum.inductiveautomation.com/u/Esmeralda_Lopez)\
**Post date:** [January 5, 2023, 7:45pm UTC](https://forum.inductiveautomation.com/t/printing-report-viewer/68276/3 "2023-01-05T19:45:51Z")

</div>

I found the function:

`system.report.executeReport(path` `=` `"My Path"` `, project` `=` `"MyProject"` `, parameters` `=` `overrides, fileType` `=` `"pdf"` `)`

But, am I need to put all parameters that says ?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 5, 2023, 7:47pm UTC](https://forum.inductiveautomation.com/t/printing-report-viewer/68276/4 "2023-01-05T19:47:59Z")

</div>

Yes, you need to supply all parameters. Also, the return value is the byte array of the PDF. You then have to print that, which isn't very convenient. Which is why I recommend the other function.

---

<div class="post-metadata">

**Author:** ![Esmeralda\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Esmeralda\_Lopez](https://forum.inductiveautomation.com/u/Esmeralda_Lopez)\
**Post date:** [January 5, 2023, 7:50pm UTC](https://forum.inductiveautomation.com/t/printing-report-viewer/68276/5 "2023-01-05T19:50:45Z")

</div>

So, If my printer is reachableI just need to use `system.report.executeAndDistribute()` ?

It will be like this:

`settings ` `=` `{` `"path"` `:` `"C:\\Ignition Reports"` `, ` `"fileName"` `:` `"Report.pdf"` `, ` `"format"` `:` `"pdf"` `}`

`system.report.executeAndDistribute(path` `=` `"My Report Path"` `, project` `=` `"My Project"` `, action` `=` `"print"` `, actionSettings` `=` `settings)`

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 5, 2023, 8:03pm UTC](https://forum.inductiveautomation.com/t/printing-report-viewer/68276/6 "2023-01-05T20:03:27Z")

</div>

Reachable by the gateway (that's where reports are generated). If your action is print, you supply action settings for "print" to designate the printer to target. (Your sample has action settings for "save", which would save into the gateway's filesystem.)

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

And don't forget to supply parameters for the report itself.

---

<div class="post-metadata">

**Author:** ![Esmeralda\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Esmeralda\_Lopez](https://forum.inductiveautomation.com/u/Esmeralda_Lopez)\
**Post date:** [January 5, 2023, 8:16pm UTC](https://forum.inductiveautomation.com/t/printing-report-viewer/68276/7 "2023-01-05T20:16:08Z")

</div>

OK, so the path in 'settings' is where the reports are generated in the computer and in the function executeAndDsitribute , the ''path" is the name that my report has?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 5, 2023, 9:26pm UTC](https://forum.inductiveautomation.com/t/printing-report-viewer/68276/8 "2023-01-05T21:26:57Z")

</div>

No, when printing, you don't supply `path` or `fileName` or `format` in your actionSettings. You supply `primaryPrinterName` and/or `backupPrinterName` and so on. When just printing, the PDF isn't saved to disk anywhere.

Use `path`, `fileName`, and `format` when using the `save` action. Then the gateway filesystem gets the result.

Please take a closer look in the docs where all of the `actionSettings` are described.

---

<div class="post-metadata">

**Author:** ![Esmeralda\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Esmeralda\_Lopez](https://forum.inductiveautomation.com/u/Esmeralda_Lopez)\
**Post date:** [January 5, 2023, 11:20pm UTC](https://forum.inductiveautomation.com/t/printing-report-viewer/68276/9 "2023-01-05T23:20:39Z")

</div>

Yes, I mean, don't change the word path, I waas trying to say the value , and I tried to do this but don't do anything.

```auto
settings = {"path":"C:\\Users\\Em\\Desktop", "fileName":"Report.pdf", "format":"pdf"}
system.report.executeAndDistribute(path="ejemplo", project="Prueba", action="save", actionSettings=settings)

```

I tried first just saving the report

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 6, 2023, 1:22am UTC](https://forum.inductiveautomation.com/t/printing-report-viewer/68276/10 "2023-01-06T01:22:23Z")

</div>

Does your gateway service have access to your user home desktop? The gateway background process is what creates and then saves or prints or emails your report. The gateway service generally does not have access to user home directories. And it is usually pointless, as most installs don't have users logging into the server's desktop.

If you want to save locally in Vision, use `system.report.executeReport()` and then `system.file.writeFile()` to write the bytes of the PDF where you want them.

Saving and printing are sufficiently different that the easiest solution is different for each.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 6, 2023, 1:24am UTC](https://forum.inductiveautomation.com/t/printing-report-viewer/68276/11 "2023-01-06T01:24:09Z")

</div>

{ Look in your gateway log for errors produced by the attempts to save there. Very unlikely to be "nothing". }
