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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
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: 40061
    
  28
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://aspose.com/file-tools
 
subject: Strange behavior of Java Printing API