Advertisement

05.14.2008 at 08:22AM PDT, ID: 23401781 | Points: 500
[x]
Attachment Details

Java application printing is truncated near end of page when running on MAC

Asked by John4343 in Java Programming Language, Mac OS X

Tags: Apple Mac, Java, OSX 10.4 10.5

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(book);
      boolean doPrint = printerJob.printDialog();

      if (doPrint) {
         try {
            printerJob.print();
            .......


I found an earlier solution and tried:

PrintRequestAttributeSet  pras = new HashPrintRequestAttributeSet();
PrintService service = null;
java.awt.print.PrinterJob pjob = java.awt.print.PrinterJob.getPrinterJob();
      
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_FORMATTED.PAGEABLE, das);
      DocPrintJob job1 = service.createPrintJob();
      try{
            job1.print(doc, pras);
                }
      catch(Exception e){
             System.err.println("Printing error: " + e);
                }
}

This works on Windows but on MAC  gives a null pointer exception on job1.print(doc, pras);

Thanks      
   Start Free Trial
[+][-]05.15.2008 at 02:06AM PDT, ID: 21571669

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 04:59AM PDT, ID: 21572510

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 05:34AM PDT, ID: 21572769

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 07:02AM PDT, ID: 21606205

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 07:12AM PDT, ID: 21606311

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 10:30AM PDT, ID: 21608337

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 01:33PM PDT, ID: 21610088

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.21.2008 at 11:12AM PDT, ID: 21617524

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 12:54AM PDT, ID: 21621666

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628