# Power Table printing, fit to page

**URL:** <https://forum.inductiveautomation.com/t/power-table-printing-fit-to-page/22456>\
**Category:** Ignition\
**Created:** [February 8, 2019, 11:45pm UTC](https://forum.inductiveautomation.com/t/power-table-printing-fit-to-page/22456 "2019-02-08T23:45:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [February 8, 2019, 11:45pm UTC](https://forum.inductiveautomation.com/t/power-table-printing-fit-to-page/22456/1 "2019-02-08T23:45:38Z")

</div>

I am able to print the power table with the script below with a mouse click but it is very hard to see. Is there away to fit it to the page so it is more readable?

```auto
# Get a reference to the power table
powerTable = event.source.parent.getComponent("Power Table") # Get a reference to the table
powerTable.print()

```

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [February 10, 2019, 1:56pm UTC](https://forum.inductiveautomation.com/t/power-table-printing-fit-to-page/22456/2 "2019-02-10T13:56:06Z")

</div>

Has anyone done this before in scripting? or I found this. (.setFitToPage) But I am not for sure how to add it.

---

<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:** [February 10, 2019, 2:15pm UTC](https://forum.inductiveautomation.com/t/power-table-printing-fit-to-page/22456/3 "2019-02-10T14:15:55Z")

</div>

Try using [system.print.createPrintJob()](https://docs.inductiveautomation.com/display/DOC79/system.print.createPrintJob) instead of your table’s .print() method.

{ Edit: s/util/print/ }

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [February 10, 2019, 2:26pm UTC](https://forum.inductiveautomation.com/t/power-table-printing-fit-to-page/22456/4 "2019-02-10T14:26:45Z")

</div>

I get this error

```auto
Traceback (most recent call last):

  File "<event:actionPerformed>", line 4, in <module>

AttributeError: 'com.inductiveautomation.ignition.common.script.Imm' object has no attribute 'createPrintJob'

```

Script I tried

```auto
powerTable = system.util.createPrintJob(event.source.parent.getComponent("Power Table"))
powerTable.print()

```

---

<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:** [February 10, 2019, 3:18pm UTC](https://forum.inductiveautomation.com/t/power-table-printing-fit-to-page/22456/5 "2019-02-10T15:18:24Z")

</div>

Sorry, typo. Lesson: use the linked examples, not the typo in my post. Take note of that error message – it usually means a typo in a function name. I also don’t recommend you keep the “powerTable” variable name for a print job – not if you want to understand this code when you revisit it next year.

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [February 10, 2019, 6:07pm UTC](https://forum.inductiveautomation.com/t/power-table-printing-fit-to-page/22456/6 "2019-02-10T18:07:23Z")

</div>

I got it to work with the script from the link but this is what it prints. It cuts it off and doesn’t fit it to the page.  
 ![Capture](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/587498813a4cdaa6df6b0d298b412ee20246bc75.png)

Here is the script i am using

```auto
job = system.print.createPrintJob(event.source.parent.getComponent('Power Table'))
job.setShowPrintDialog(1)
job.setPageHeight(11)
job.setPageWidth(8.5)
job.setMargins(.5)
job.setFitToPage(1)
job.setOrientation(1)
job.setZoomFactor(.4)
job.print()

```

---

<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:** [February 10, 2019, 6:36pm UTC](https://forum.inductiveautomation.com/t/power-table-printing-fit-to-page/22456/7 "2019-02-10T18:36:49Z")

</div>

I would expect fit-to-page and zoom factor to be contradictory. Since zoom is later in your code, it seems to have overridden the fit-to-page option.

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [February 10, 2019, 7:23pm UTC](https://forum.inductiveautomation.com/t/power-table-printing-fit-to-page/22456/8 "2019-02-10T19:23:21Z")

</div>

with zoom commented out it shows the full powertable from side to side when you print it but it doesn’t fit it to the full page length wise

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [February 10, 2019, 7:59pm UTC](https://forum.inductiveautomation.com/t/power-table-printing-fit-to-page/22456/9 "2019-02-10T19:59:59Z")

</div>

even if I take every thing out of the code like this it still doesn’t fit it to the page

```auto
job = system.print.createPrintJob(event.source.parent.getComponent('Power Table'))
job.setFitToPage(1)
#job.setShowPrintDialog(1)
#job.setPageHeight(11)
#job.setPageWidth(8.5)
#job.setMargins(.5)
#job.setOrientation(1)
#job.setZoomFactor(.25)
job.print()

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 11, 2019, 4:42pm UTC](https://forum.inductiveautomation.com/t/power-table-printing-fit-to-page/22456/10 "2019-02-11T16:42:28Z")

</div>

The system.print function doesn’t perform layout again (I believe) - so the print job will keep the same aspect ratio as whatever client is actively rendering it/however it was laid out in the designer. It will scale one axis to fit (in this case width) but not reflow the contents to fit vertically. This is just a limitation of the system.print functions. You may need to look into the reporting module if you need dynamic printouts of data.
