aspose file tools
The moose likes Other JSE/JEE APIs and the fly likes Strange behavior of Java Printing API Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Reply Bookmark "Strange behavior of Java Printing API" Watch "Strange behavior of Java Printing API" New topic
Author

Strange behavior of Java Printing API

Karthikeyan Chandrasekaran
Greenhorn

Joined: Feb 10, 2006
Posts: 15
Hi All,

I have just tried the following code and the results are different. Can anyone tell why this happens?

import javax.print.*;

public class Printer {


public static void main(String[] args) {

DocFlavor[] flavors = {DocFlavor.SERVICE_FORMATTED.PRINTABLE};

PrintService[] pServices =
PrintServiceLookup.lookupPrintServices(flavors[0], null);


System.out.println("===PrintService===");

for(int i=0; i< pServices.length; i++) {

System.out.println(pServices.getName());

}

pServices = PrintServiceLookup.lookupMultiDocPrintServices(flavors, null);


System.out.println("===MultiDoc PrintService===");

for(int i=0; i< pServices.length; i++) {

System.out.println(pServices.getName());
}

}

}


Here lookupPrintServices() method returns all the printers installed in my machine, but lookupMultiDocPrintServices() returns empty.

I am using Java 5 in Windows 2000.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32708
    
    4
Have look at the two methods in the API. the one about MultPrint will only print if your printer supports all the flavours given.
Karthikeyan Chandrasekaran
Greenhorn

Joined: Feb 10, 2006
Posts: 15
I have passed an array of flavors to lookupMultiDocPrintServices() method, but the array contains only one element.(Please look at my code). So the result should be same for lookupMultiDocPrintServices() and lookupPrintServices(). But still lookupMultiDocPrintServices() returns empty.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Strange behavior of Java Printing API
 
Similar Threads
[PrintService] Pb while printing
How to get List of Client Printers
javax.print in ejb
Get the list of printers configured on the Server machine via a JSP page
Trouble Printing with java 1.4!