Printing with Attributes(Tray Control, Duplex, etc…) using javax.print library

The problem is that the the Java print API is a bridge between worlds. Printer manufacturers don’t release drivers for the JVM. They release drivers for Windows, Macintosh, and maybe someone has a a driver for a given printer that works on one or more *nix platforms.

Along you come with some Java code running inside a JVM on some host system. When you start querying the printer features, you aren’t talking to the printers — you are talking to a bridge class in java.awt.print that hook into the JVM, which hooks to the host operating system, which hooks into whatever particular driver was installed for a given printer. So there are several places where this can fall apart… The particular JVM you are on may or may not fully implement the API for querying printer features, let alone passing those parameters along for a given job.

A few suggestions:

  1. look into the javax.print classes as an alternative to
    java.awt.print — I’ve had more luck printing from there.
  2. try using alternative print drivers for your printers — you can define
    multiple named connections to a given printer, each with a different
    driver. If you’ve got a manufacturer provided driver, try a more generic driver, if you’ve got a generic driver, try to install a more specific one.
  3. run your code under alternate JVM implementations for your platform

Leave a Comment