Set the Orientation of a Printed Page in Java
Description
The following code shows how to set the Orientation of a Printed Page.
Example
//ww w. jav a2 s.com
import java.awt.print.PageFormat;
import java.awt.print.PrinterJob;
public class Main {
public static void main(String[] argv) throws Exception {
PrinterJob pjob = PrinterJob.getPrinterJob();
PageFormat pf = pjob.defaultPage();
pf.setOrientation(PageFormat.PORTRAIT);
pf.setOrientation(PageFormat.LANDSCAPE);
// pjob.setPrintable(printable, pf);
pjob.print();
}
}