Printing many PDFs
Hi,
I try to print many PDF files but the user of corse should get the print-Dialog only once. I use JPedal and the java printing library. (J 1.4.2) The main problem I found was that it was possible but it somehow remembers only the number of pages from the document wich the printdialog was made for. So if the first document only had 2 pages, it printed only the maximum of 2 pages for all the other Documents. Every way I tried to set the number of pages failed....
As a workaround I now make one big PDF File of all documents and then print it. The problem is that like this you can't print a large number of documents as the file gets way to big.
Any Ideas?
PrinterJob printJob = Application.getPrintJob();
// like this I can remember the printjob
if ( printJob == null ) {
printJob = PrinterJob.getPrinterJob();
Application.setPrintJob(printJob);
}
// setting Page-Format
PageFormat pf = printJob.defaultPage();
Paper paper = new Paper();
paper.setSize(594, 841);
paper.setImageableArea(0, 0, 594, 841);
pf.setPaper(paper);
pdfDecoder.setPageFormat(pf);
// Print-Job Name setzen
printJob.setJobName("LGT-Class Print");
// PDF-Viewer an PrintJob 黚ergeben
pdfDecoder.setPrintAutoRotateAndCenter(true);
// here I set the pagerange
pdfDecoder.setPagePrintRange(new PageRanges(1, pdfDecoder.getPageCount()));
printJob.setPageable(pdfDecoder);
// showPrintDialog is only true when it comes in the first time
if ( showPrintDialog ) {
if( !printJob.printDialog() ) {
printMade = false;
return;
}
}
OnlineIndikator.setIndeterminate(true);
if (showPrintDialog) {
printJob.print();
} else {
// here I try to set the pagerange myself.. but with no sucess
PrintRequestAttributeSet as = new HashPrintRequestAttributeSet();
PageRanges range = new PageRanges(1, pdfDecoder.getPageCount());
as.add(range);
printJob.print(as);
}
OnlineIndikator.setIndeterminate(false);
}

