Printing API: no services

Discussion in 'Java' started by Karsten Wutzke, Feb 11, 2004.

  1. Hi all!

    I really just want to print something very simple - just a plain text
    string. But it doesn't work... PrintServiceLookup.lookupPrintServices
    returns a zero length (or empty) array of print services.

    //get plain text string doc flavor
    DocFlavor df = DocFlavor.STRING.TEXT_PLAIN;

    //make doc
    Doc doc = new SimpleDoc(strOutputSchedule, df, null);

    //get services
    PrintService[] services = PrintServiceLookup.lookupPrintServices(df, null);

    if ( services.length>0 )
    DocPrintJob job = services[0].createPrintJob();

    job.print(doc, pras);

    catch ( PrintException pe )
    System.err.println("Print exception!");
    System.out.println("No printer found!");

    This code will print "No printer found!" to the console all the time.

    Looks like I don't have the simplest service installed. How can I get it
    to work without having to worry about other users having to install
    working print services manually??

    Can anyone help?

    Karsten Wutzke, Feb 11, 2004
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.