Displaying the Page Format Dialog: changes the default page format such as orientation and paper size. : Print « 2D Graphics GUI « Java






Displaying the Page Format Dialog: changes the default page format such as orientation and paper size.

    

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.LANDSCAPE);

    pf = pjob.pageDialog(pf);
  }
}

   
    
    
    
  








Related examples in the same category

1.The Printing code which implements Printable
2.Print an Image to print directly
3.Simplest SWT Print ExampleSimplest SWT Print Example
4.Print in Java 2: PrinterJob
5.Print in Java: page format and document
6.Print in Java: Multi page
7.Print in Java 5
8.Print in Java 6
9.Simple Book for printingSimple Book for printing
10.Shapes PrintShapes Print
11.Display the print dialog and print
12.Print the printable area outlinePrint the printable area outline
13.Print the text file and print preview themPrint the text file and print preview them
14.Printable demoPrintable demo
15.Print Swing componentsPrint Swing components
16.BookBook
17.Another print demoAnother print demo
18.Book demoBook demo
19.Printing the Combined-Java 1.2-and-1.4 WayPrinting the Combined-Java 1.2-and-1.4 Way
20.Printing the Java 1.4 Way
21.Prompting for a Printer
22.Printing the Java 1.1 WayPrinting the Java 1.1 Way
23.ScribbleScribble
24.Printable Document
25.PrintFile -- Print a file named on the command linePrintFile -- Print a file named on the command line
26.Print to the standard output
27.PrintPanel is the base for an open-ended series of classesPrintPanel is the base for an open-ended series of classes
28.Pageable TextPageable Text
29.The area of the printable area
30.The area of the actual page
31.Printing Pages with Different Formats
32.Setting the Orientation of a Printed Page
33.Print Dialog: change the default printer settings(default printer, number of copies, range of pages)
34.Printing to a File
35.Listening for Print Service Status Changes
36.Print Image
37.Overriding the Default Action of a JTextComponent
38.Printable Component
39.Create PageFormats on a higher level
40.Printing of a multi-page bookPrinting of a multi-page book