Printing multiple Vision Client pages in one print job

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?

No.

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

Hello PGriffith,

Thank you for the quick response!

I took your advice and created a printerjob

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

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()