I would like to print multiple pdfs from java (using the java print service) in a single print job.
I would like to send multiple pdfs as a single job to the printe
I met the same difficulties when printing at once several JPanels of a JTabbedPane, each on a separate page. I gather them in a Book but it only prints the first page.
The Book class works well (right number of pages), but I suppose the problem comes from setPageable. Since a Book is not a Printable, I made it, and it works !
Workaround:
Design a PrintableBook class : extends Book, implements Printable
public class PrintableBook extends Book implements Printable {
Vector pages;// NB: we assume pages are single
public PrintableBook() {
super();
pages = new Vector();
}
public void add(Printable pp) {
append(pp, pp.getPageFormat());
pages.add(pp);
}
public int print(Graphics g, PageFormat pf, int pageIndex) {
if (pageIndex >= pages.size())
return NO_SUCH_PAGE;
else {
Printable pp = pages.elementAt(pageIndex);
return pp.print(g, pf, 0);
}
}
}
Then use printJob.setPrintable( printableBook )
instead of setPageable