The following code prints multi-page reports fine on Windows. Under MAC OSx 10.4 or 10.5 the printed output is truncated about 3/4 way down the page.
...
book.append(printText, reportFormat);
...
printerJob.setPageable(boo
k);
boolean doPrint = printerJob.printDialog();
if (doPrint) {
try {
printerJob.print();
.......
I found an earlier solution and tried:
PrintRequestAttributeSet pras = new HashPrintRequestAttributeS
et();
PrintService service = null;
java.awt.print.PrinterJob pjob = java.awt.print.PrinterJob.
getPrinter
Job();
PrintService printService[] = pjob.lookupPrintServices()
;
if (printService == null || printService.length == 0) {
System.err.println ("Error 1");
return;
}
if (pjob.printDialog()){
service = pjob.getPrintService();
}else{
service = null;
}
if (service!=null){
DocAttributeSet das = new HashDocAttributeSet();
Doc doc = new SimpleDoc(book, DocFlavor.SERVICE_FORMATTE
D.PAGEABLE
, das);
DocPrintJob job1 = service.createPrintJob();
try{
job1.print(doc, pras);
}
catch(Exception e){
System.err.println("Printi
ng error: " + e);
}
}
This works on Windows but on MAC gives a null pointer exception on job1.print(doc, pras);
Thanks
Start Free Trial