# Ignition 8.0 " Print Screen Button" script example

**URL:** <https://forum.inductiveautomation.com/t/ignition-8-0-print-screen-button-script-example/31155>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [January 8, 2020, 6:04pm UTC](https://forum.inductiveautomation.com/t/ignition-8-0-print-screen-button-script-example/31155 "2020-01-08T18:04:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [January 8, 2020, 6:04pm UTC](https://forum.inductiveautomation.com/t/ignition-8-0-print-screen-button-script-example/31155/1 "2020-01-08T18:04:11Z")

</div>

Is there an example that shows the method to print out a VISION display using a button script?

I found some old (2010) references but they don’t work in Ignition 8.0

obj = system.gui.getParentWindow(event) .parent  
printJob = system.print.createPrintJob(obj)  
printJob.showPrintDialog = 0  
printJob.orientation = system.print.LANDSCAPE  
printJob.print()

Thanks

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [January 8, 2020, 6:34pm UTC](https://forum.inductiveautomation.com/t/ignition-8-0-print-screen-button-script-example/31155/3 "2020-01-08T18:34:28Z")

</div>

I think you need you doing sstem.getParentWindow.parent is the issue. Whats the windows parent? You need to give it a component, and I’m not sure what class or object the parent of a window is but it’s definitely not a component.

Try following the second example in the documentation with your root container or just the window.

[https://docs.inductiveautomation.com/display/DOC79/system.print.createPrintJob](https://docs.inductiveautomation.com/display/DOC79/system.print.createPrintJob)

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [January 8, 2020, 6:49pm UTC](https://forum.inductiveautomation.com/t/ignition-8-0-print-screen-button-script-example/31155/4 "2020-01-08T18:49:34Z")

</div>

I guess my confusion is the difference between “root container” and “The window that the button is on”

---

<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 8, 2020, 7:13pm UTC](https://forum.inductiveautomation.com/t/ignition-8-0-print-screen-button-script-example/31155/5 "2020-01-08T19:13:12Z")

</div>

It’s complicated. Try this script on a button’s actionPerformed event:

```auto
current = event.source
hierarchy = [current]
while current.parent:
	current = current.parent
	if current in hierarchy:
		break
	else:
		hierarchy.insert(0, current)
for x in hierarchy:
	print x.getClass().canonicalName

```

In a v7.9 designer I get this:

```auto
com.inductiveautomation.ignition.designer.IgnitionDesigner
javax.swing.JRootPane
javax.swing.JLayeredPane
javax.swing.JPanel
com.jidesoft.swing.ContentContainer
com.jidesoft.action.MainContainer
javax.swing.JPanel
com.jidesoft.docking.DefaultDockingManager.MainPanel
com.jidesoft.docking.DefaultDockingManager.DockedHiddenSlidingContainer
javax.swing.JPanel
com.jidesoft.docking.ContainerContainer
com.jidesoft.docking.DockedFrameContainer
javax.swing.JPanel
com.jidesoft.docking.ContainerContainer
com.jidesoft.docking.ContainerContainer
com.jidesoft.docking.ContainerContainer
com.jidesoft.docking.Workspace
com.inductiveautomation.ignition.designer.WorkspaceManager
javax.swing.JPanel
com.inductiveautomation.factorypmi.designer.workspace.WindowWorkspace
com.inductiveautomation.ignition.designer.designable.DesignPanel
javax.swing.JViewport
com.inductiveautomation.ignition.designer.designable.DesignPanel.LayerParent
com.inductiveautomation.ignition.designer.designable.DesignPanel.DesignableContainerLayer
com.inductiveautomation.factorypmi.application.FPMIWindow
javax.swing.JRootPane
javax.swing.JLayeredPane
com.inductiveautomation.factorypmi.application.components.BasicContainer
com.inductiveautomation.factorypmi.application.components.PMIButton

```

Everything in that list is a “Component” as far as java is concerned. The “Root Container” is that BasicContainer on the second to last line. The window is three lines above that.

---

<div class="post-metadata">

**Author:** ![PLCINC\_NY](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/plcinc_ny/32/20350_2.png) [@PLCINC\_NY](https://forum.inductiveautomation.com/u/PLCINC_NY)\
**Post date:** [January 8, 2020, 7:55pm UTC](https://forum.inductiveautomation.com/t/ignition-8-0-print-screen-button-script-example/31155/6 "2020-01-08T19:55:40Z")

</div>

Thanks All.

This Worked

job = system.print.createPrintJob(event.source.parent.getComponent(‘Container’))  
job.setShowPrintDialog(1)`  
job.setPageHeight(3)  
job.setPageWidth(5)  
job.setMargins(5)  
job.setOrientation(0)

`job.` `print` `()`

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [January 9, 2020, 3:59pm UTC](https://forum.inductiveautomation.com/t/ignition-8-0-print-screen-button-script-example/31155/7 "2020-01-09T15:59:44Z")

</div>

The original code works fine, just tested it. What error are you seeing?
