Nothing happens when using java.awt.print on Mac OSX.

Discussion in 'Java' started by Aubrey Jones, Aug 11, 2004.

  1. Aubrey Jones

    Aubrey Jones Guest

    I'm attempting to print a custom-made Swing component using the
    java.awt.print protocol. It works perfectly on Linux and Windows, but
    totally fails on Mac OSX. I googled, and found that Apple hasn't
    implemented javax.print. But, I'm not using it, unless it's hidden
    somewhere in the support classes for awt.print.

    Anyway, the symptoms: neither printing nor print previews work; the
    printer apparently comes out of sleep mode, but doesn't even print so
    much as a blank piece of paper. Also, from tracing, I know that my
    component's print() gets called.

    I'm at my wit's end currently, going generally nuts over this. I'm
    including my print code at the bottom. The first method handles the
    printing, the second is my Printable.print() implementation (without
    graphics code).

    Any help would be most appreciated.

    ARJ




    /**
    * Does printing.
    * */
    public void printBodyImage(){
    curSession.clientName = clientField.getText();
    curSession.investigatorName = investigatorField.getText();
    PrinterJob printJob = PrinterJob.getPrinterJob();

    //printJob.setPrintable(sessionPanel);


    if (printJob.printDialog()){
    try {
    printJob.setPrintable(sessionPanel, printJob.defaultPage());
    printJob.print();
    } catch (PrinterException pe) {
    RFIErrorHandler.nonfatal(pe);
    }
    }

    }


    /**
    * Prints this object.
    * */
    public int print(Graphics g, PageFormat pageFormat, int pageIndex){
    if (pageIndex > 0) {
    return(NO_SUCH_PAGE);
    }
    Graphics2D g2d = (Graphics2D)g;
    g2d.setBackground(Color.WHITE);

    g2d.translate(pageFormat.getImageableX(), (pageFormat.getImageableY()
    + 72));
    //These are the functions that do the actual rendering.
    //They work fine on Windows and *nix, so I don't think they're
    a prob.
    computeScaleFactor(pageFormat.getImageableWidth(),
    pageFormat.getImageableHeight() - 72);
    this.drawPrint(g2d, (int) pageFormat.getImageableWidth(), (int)
    pageFormat.getImageableHeight() - 72);

    return (PAGE_EXISTS);
    }
     
    Aubrey Jones, Aug 11, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Saunders

    Re: No Error and nothing happens!

    John Saunders, Jun 30, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    340
    Kevin Spencer
    Jun 30, 2004
  2. Steve

    listbox click - nothing happens?

    Steve, Aug 19, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,848
    Steve
    Aug 20, 2004
  3. Robert Mark Bram
    Replies:
    2
    Views:
    5,986
    Robert Mark Bram
    Dec 11, 2003
  4. hiwa
    Replies:
    1
    Views:
    1,151
    Thomas Weidenfeller
    Mar 9, 2005
  5. NM
    Replies:
    6
    Views:
    480
    Default User
    Sep 20, 2006
Loading...

Share This Page