3 Replies Latest reply: Sep 20, 2011 1:38 PM by 809490 RSS

    printing PDF on Macintosh

    809490
      Hello

      I have an application, which has to write PDF files using java.awt.print.Printable and which works fine on Windows clients.
      Now I want to do the same on Macintosh, but I just get a dialog with "Keine Druckdienste gefunden", which means "No printservices available".

      The class looks like this
      public class Fax2 implements Printable
      {
           ...
           @Override
           public int print(Graphics g, PageFormat pf, int pi)
                     throws PrinterException 
           {
                      Graphics2D  g2 = (Graphics2D) g;
                      g2.drawLine(175, 170, 600, 170);
                      ...
                       
              }
      
      }
      and it gets called like this
                              Fax2 fax = new Fax2();
                     PrinterJob printjob = PrinterJob.getPrinterJob();
                     printjob.setPrintable(fax);
                     try
                     {
                          HashPrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
                          attr.add(OrientationRequested.LANDSCAPE);
                          boolean printAccepted = printjob.printDialog(attr);  
                         if (printAccepted)
                              printjob.print(attr);
                     }
                     catch(PrinterException e)
                     {
                          e.printStackTrace();
                     }
      Kind regards,
      Chang
        • 1. Re: printing PDF on Macintosh
          793415
          Have you tried:
          Desktop.getDesktop().print(new File("the.pdf"));
          ?
          • 2. Re: printing PDF on Macintosh
            809490
            Thanks for your help Andrew.
            Sorry there is something more to say. On the windows machine I installed a PDF printer, which i can choose in the PrintJob.printDialog() Dialog to build a PDF.
            On Macintosh there is this functionallity normally built in so there is no need to install a pdf printer, but java does not open the native Macintosh print Dialog and I'm not able to produce a PDF on Macintosh.
            Therefore I don't know which file to give to
            Desktop.getDesktop().print(new File("???"));
            regards,
            Chang
            • 3. Re: printing PDF on Macintosh
              809490
              Is the question not clear or is there no easy solution for this?
              I will rephrase it and i hope it gets clearer.

              On windows I have to install a third party pdf-printer and then user is able to choose this pdf-printer from the java-printdialog.
              On macintosh there is a native pdf-printer and i want to use this native printer, because i cannot find other pdf-printers for macintosh, but for this i need the native macintosh printdialog to open...
              Currently I'm not able to open any printdialog neither java nor native on macintosh.