|
Description
|
Using Java 2 SDK 1.2.2, REVERSE_LANDSCAPE printer orientation
may result in nothing being printedThe new printing API in JDK 1.2 supports several paper orientations.
With JDK 1.2 LANDSCAPE and REVERSE_LANDSCAPE were ignored (when not
printing a raster).
That was filed as bug 4186119 which fixed the LANDSCAPE case.
Now however, REVERSE_LANDSCAPE seems to have an effect: but it appears
it transforms the drawing righf off the device/page.
The following test case from "J.Ganesan" < xxxxx@xxxxx >
which simply did not set orientation on 1.2FCS, now
(using JDK 1.2.2) shows nothing on the page at all.
import javax.swing.* ;
import java.awt.* ;
import java.awt.print.* ;
public class HorizontalLine implements Printable
{
public HorizontalLine()
{
super() ;
}
public void paint( Graphics g )
{
g.setColor(Color.black);
g.drawLine( 100 , 100 , 300 , 100 ) ;
}
public int print(Graphics g, PageFormat pf, int pi) throws PrinterException
{
if (pi >= 1) {
return Printable.NO_SUCH_PAGE;
}
paint(g);
return Printable.PAGE_EXISTS;
}
public static void main( String[] args )
{
// Get a PrinterJob
PrinterJob prnJob = PrinterJob.getPrinterJob();
PageFormat pf = prnJob.defaultPage();
pf.setOrientation(PageFormat.REVERSE_LANDSCAPE);
prnJob.setPrintable(new HorizontalLine() , pf );
try
{
prnJob.print();
}
catch (PrinterIOException e)
{ /* handle exception */
System.out.println( e ) ;
}
catch (Exception e)
{ /* handle exception */
System.out.println( e ) ;
}
}
}
|