Printing API: no services

K

Karsten Wutzke

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();

try
{
job.print(doc, pras);

}
catch ( PrintException pe )
{
System.err.println("Print exception!");
}
}
else
{
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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top