|
Description
|
When using the COMMON Dialog for printing, it presents a complete list of MediaTypes without checking if the currently selected printer supports each size. This allows the user to select a MediaType which the printer cannot handle. However, when the dialog is closed, the java.awt.print.PageAttributes object for the PrintJob, has been modified so that its PageAttributes.MediaType value is an acceptable value for the printer.
Example Code:
import java.awt.*;
import java.awt.print.*;
public class Test
{
public static void main( String[] args )
{
JobAttributes ja = new JobAttributes();
PageAttributes pa = new PageAttributes();
ja.setDialog( JobAttributes.DialogType.COMMON );
JobAttributes ja2 = new JobAttributes( ja );
PageAttributes pa2 = new PageAttributes( pa );
PrintJob pj = Toolkit.getDefaultToolkit().getPrintJob( new Frame() ,
"Test me" , ja2 , pa2 );
System.out.println( "Page properties before" );
System.out.println( pa );
System.out.println( "Page properties after" );
System.out.println( pa2 );
System.exit( 1 );
}
}
Produces the following output when printing to an 'Apple II NTX Laserwriter', trying to print to size A10
Page properties before
color=monochrome, media=iso-a4, orientation-requested=portrait, origin=physical, print-quality=normal, printer-resolution=[72,72,3]
Page properties after
color=monochrome, media=jis-b5, orientation-requested=portrait, origin=physical, print-quality=normal, printer-resolution=[72,72,3]
-------- End of output
The MediaType has been rounded up to B5
The results are reproducable (and therefore predictable), but the size that it uses instead is not obvious. This happens with any printer that I select.
Ideally the MediaType list should be reduced to the available sizes for each printer.
Java Version:
C:\>java -version
java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)
C:\>java -fullversion
java full version "1.3beta-O"
(Review ID: 94386)
======================================================================
|
|
Evaluation
|
This is a good suggestion. Unfortunately, because Solaris lacks a true printing
interface, this is only implementable on Windows. Nevertheless, the code is only
a day's work, so this is worth doing for kestrel.
xxxxx@xxxxx 1999-08-25
Implemented limited printer capabilities functionality which is used by the
cross-platform print dialog only. I test for valid paper sizes and duplex
support only. I tried to test for color support but ran into a conundrum: even
if a printer doesn't support color printing, the user may still want to generate
a color file. I could toggle color support based on the printing destination,
but since color and destination are on two different tabs of the print dialog,
this would probably be very confusing.
xxxxx@xxxxx 1999-10-10
|