The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.awt.print  [6 examples]

e683. Setting the Orientation of a Printed Page

    PrinterJob pjob = PrinterJob.getPrinterJob();
    PageFormat pf = pjob.defaultPage();
    
    if (portrait) {
        pf.setOrientation(PageFormat.PORTRAIT);
    } else {
        pf.setOrientation(PageFormat.LANDSCAPE);
    }
    
    pjob.setPrintable(printable, pf);
    try {
        pjob.print();
    } catch (PrinterException e) {
    }

 Related Examples
e681. The Quintessential Printing Program
e682. Getting the Dimensions of a Printed Page
e684. Printing Pages with Different Formats
e685. Displaying the Page Format Dialog
e686. Displaying the Print Dialog


© 2002 Addison-Wesley.