# Printing multiple Vision Client pages in one print job

**URL:** <https://forum.inductiveautomation.com/t/printing-multiple-vision-client-pages-in-one-print-job/53334>\
**Category:** Ignition\
**Created:** [November 22, 2021, 1:11pm UTC](https://forum.inductiveautomation.com/t/printing-multiple-vision-client-pages-in-one-print-job/53334 "2021-11-22T13:11:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajith\_Asokan](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ajith\_Asokan](https://forum.inductiveautomation.com/u/Ajith_Asokan)\
**Post date:** [November 22, 2021, 1:11pm UTC](https://forum.inductiveautomation.com/t/printing-multiple-vision-client-pages-in-one-print-job/53334/1 "2021-11-22T13:11:56Z")

</div>

I wish to print the pages (of type com.inductiveautomation.factorypmi.application.FPMIWindow) that I created in ignition in one single print job, as consecutive pages. Using createPrintJob, I am able to choose only one page per print job. Is there a straightforward way of achieving this by using Jython scripting?

---

<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:** [November 22, 2021, 5:18pm UTC](https://forum.inductiveautomation.com/t/printing-multiple-vision-client-pages-in-one-print-job/53334/2 "2021-11-22T17:18:03Z")

</div>

No.

You’ll probably have to create your own print job; we don’t expose enough of JythonPrintJob to really do this.

---

<div class="post-metadata">

**Author:** ![Ajith\_Asokan](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ajith\_Asokan](https://forum.inductiveautomation.com/u/Ajith_Asokan)\
**Post date:** [November 25, 2021, 2:55pm UTC](https://forum.inductiveautomation.com/t/printing-multiple-vision-client-pages-in-one-print-job/53334/3 "2021-11-25T14:55:30Z")

</div>

Hello PGriffith,

Thank you for the quick response!

I took your advice and created a printerjob

```auto
book = Book()

P1 = system.gui.getWindow('P1')
P2 = system.gui.getWindow('P2')

printable1 = ComponentPrinter(P1, True, -1)
printable2 = ComponentPrinter(P2, True, -1)

job = PrinterJob.getPrinterJob()
pf = job.defaultPage()

# Create a letter sized piece of paper with one inch margins
paper = Paper()

# resize the paper and the imageable area
width = P1.getWidth()
height = P1.getHeight()
paper.setSize(width, height)
paper.setImageableArea(0, 0, width, height)

# set paper for the pageFormat
pf.setPaper(paper)

bk = Book()
bk.append(printable1, pf)
bk.append(printable2, pf)

job.setPageable(bk)
e = PrinterException()

if job.printDialog():
    try:
        job.print()
    except e:
        print "FAILED!"

```

This prints the PDF, but only the first page that is appended to the book. Explicitly specifying the number of pages while appending to the Book does not help.

I am stuck with this problem for weeks, it would be EPIC if I could find a solution!

Regards

---

<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:** [November 29, 2021, 3:21pm UTC](https://forum.inductiveautomation.com/t/printing-multiple-vision-client-pages-in-one-print-job/53334/4 "2021-11-29T15:21:10Z")

</div>

Hm, at a glance that definitely seems correct. Does the book return the correct number of pages after you’ve appended both components?  
[https://docs.oracle.com/javase/7/docs/api/java/awt/print/Book.html#getNumberOfPages()](https://docs.oracle.com/javase/7/docs/api/java/awt/print/Book.html#getNumberOfPages())

---

<div class="post-metadata">

**Author:** ![Ajith\_Asokan](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ajith\_Asokan](https://forum.inductiveautomation.com/u/Ajith_Asokan)\
**Post date:** [December 6, 2021, 3:29pm UTC](https://forum.inductiveautomation.com/t/printing-multiple-vision-client-pages-in-one-print-job/53334/5 "2021-12-06T15:29:07Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/f/8f24c70bd93242d99612fbca3140cdbbea06f8a5.png)  
The number of pages returns exactly the number of printables (components) I append to the Book. This number is also visible at the print dialog. But the final document, that is printed using this logic, has only the first page.

Also, trying to print only the second page using the print dialog creates the xps file and then deletes it automatically.

---

<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:** [December 6, 2021, 5:36pm UTC](https://forum.inductiveautomation.com/t/printing-multiple-vision-client-pages-in-one-print-job/53334/6 "2021-12-06T17:36:39Z")

</div>

Oh, boo. I didn’t notice; ComponentPrinter has a check at the beginning of its `print` method that aborts if the page index requested is not 0.

You’ll have to make your own `ComponentPrinter`-like; I tried monkey-patching `print` to always use page 0, but couldn’t get it to work:

```python
from __future__ import print_function
from java.awt.print import Book, Paper, PrinterJob
from com.inductiveautomation.factorypmi.application.script.builtin.PrintUtilities import ComponentPrinter

book = Book()

P1 = system.gui.getWindow('pta')
P2 = system.gui.getWindow('treefont')

class MultipleComponentPrinter(ComponentPrinter):
	def print(self, graphics, format, pageIndex):
		ComponentPrinter.print(self, graphics, format, 0)

printable1 = MultipleComponentPrinter(P1, True, -1)
printable2 = MultipleComponentPrinter(P2, True, -1)

job = PrinterJob.getPrinterJob()
pf = job.defaultPage()

# Create a letter sized piece of paper with one inch margins
paper = Paper()

# resize the paper and the imageable area
width = P1.getWidth()
height = P1.getHeight()
paper.setSize(width, height)
paper.setImageableArea(0, 0, width, height)

# set paper for the pageFormat
pf.setPaper(paper)

bk = Book()
bk.append(printable1, pf)
bk.append(printable2, pf)

job.setPageable(bk)

if job.printDialog():
    job.print()

```

---

<div class="post-metadata">

**Author:** ![Tim\_David](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Tim\_David](https://forum.inductiveautomation.com/u/Tim_David)\
**Post date:** [March 15, 2023, 4:53am UTC](https://forum.inductiveautomation.com/t/printing-multiple-vision-client-pages-in-one-print-job/53334/7 "2023-03-15T04:53:47Z")

</div>

When I try to print the multiple screen using this printerjob.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/d/ede0f4ce250d12b815c417a6a3b518c055980f0a.png)

I am getting below error. Correct me where it went wrong

`Traceback (most recent call last):  
File "event:actionPerformed", line 39, in   
TypeError: integer required

```
at org.python.core.Py.TypeError(Py.java:236)
at org.python.core.Py.py2int(Py.java:1955)
at org.python.core.Py.py2int(Py.java:1946)
at org.python.proxies. __builtin__ $MultipleComponentPrinter$14.print(Unknown Source)
at java.desktop/sun.print.RasterPrinterJob.printPage(Unknown Source)
at java.desktop/sun.print.RasterPrinterJob.print(Unknown Source)
at java.desktop/sun.print.RasterPrinterJob.print(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:190)
at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:208)
at org.python.core.PyObject. __call__ (PyObject.java:461)
at org.python.core.PyObject. __call__ (PyObject.java:465)
at org.python.core.PyMethod. __call__ (PyMethod.java:126)
at org.python.pycode._pyx63.f$0(<event:actionPerformed>:39)
at org.python.pycode._pyx63.call_function(<event:actionPerformed>)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1687)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:788)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:297)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
at com.sun.proxy.$Proxy59.actionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Container.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

```

Ignition v8.1.15 (b2022030114)  
Java: Azul Systems, Inc. 11.0.14.1  
`

---

<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:** [March 15, 2023, 5:02am UTC](https://forum.inductiveautomation.com/t/printing-multiple-vision-client-pages-in-one-print-job/53334/8 "2023-03-15T05:02:02Z")

</div>

Post the exact code you're using, because I have no idea what line 39 is.

---

<div class="post-metadata">

**Author:** ![Tim\_David](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Tim\_David](https://forum.inductiveautomation.com/u/Tim_David)\
**Post date:** [March 15, 2023, 5:14am UTC](https://forum.inductiveautomation.com/t/printing-multiple-vision-client-pages-in-one-print-job/53334/9 "2023-03-15T05:14:56Z")

</div>

```auto
from __future__ import print_function
from java.awt.print import Book, Paper, PrinterJob
from com.inductiveautomation.factorypmi.application.script.builtin.PrintUtilities import ComponentPrinter

book = Book()

P1 = system.gui.getWindow('Welcome')
P2 = system.gui.getWindow('Main Window')

class MultipleComponentPrinter(ComponentPrinter):
	def print(self, graphics, format, pageIndex):
		ComponentPrinter.print(self, graphics, format, 0)

printable1 = MultipleComponentPrinter(P1, True, -1)
printable2 = MultipleComponentPrinter(P2, True, -1)

job = PrinterJob.getPrinterJob()
pf = job.defaultPage()

# Create a letter sized piece of paper with one inch margins
paper = Paper()

# resize the paper and the imageable area
width = P1.getWidth()
height = P1.getHeight()
paper.setSize(width, height)
paper.setImageableArea(0, 0, width, height)

# set paper for the pageFormat
pf.setPaper(paper)

bk = Book()
bk.append(printable1, pf)
bk.append(printable2, pf)

job.setPageable(bk)

if job.printDialog():
    job.print()

```

---

<div class="post-metadata">

**Author:** ![Tim\_David](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Tim\_David](https://forum.inductiveautomation.com/u/Tim_David)\
**Post date:** [March 16, 2023, 1:44pm UTC](https://forum.inductiveautomation.com/t/printing-multiple-vision-client-pages-in-one-print-job/53334/10 "2023-03-16T13:44:35Z")

</div>

Is it solved for you? same I am also facing I have 3 pages to print but only first page only printing for me.
