File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Strange behavior of Java Printing API

 
Karthikeyan Chandrasekaran
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47258
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic