Setting the Orientation of a Printed Page - Java 2D Graphics

Java examples for 2D Graphics:Print

Description

Setting the Orientation of a Printed Page

Demo Code

import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;

public class Main {
  public static void main(String[] args) {
    PrinterJob pjob = PrinterJob.getPrinterJob();
    PageFormat pf = pjob.defaultPage();

    pf.setOrientation(PageFormat.PORTRAIT);

    pf.setOrientation(PageFormat.LANDSCAPE);

    Printable printable = null;/* w  ww  .j a  va2s  .co  m*/
    pjob.setPrintable(printable, pf);
    try {
      pjob.print();
    } catch (PrinterException e) {
    }
  }
}

Related Tutorials