Aleksander Matos <[email protected]> Fri, 26 Jul 2002 11:02:04 -0500
| Newsgroups | gmane.comp.windows.devel.java.general |
|---|---|
| Message-ID | <[email protected]> |
Hi, I am Aleksander from Peru and i have a question about how to set the
paper to A4.
I am using VisualAge for Java 3.5 with JDK 1.3
When i send to print, nothing happen, it prints on the same paper where the
printer its setting.
For example, if the printer is setting on Letter, it print on Letter, or it
one is setting on A4 it print on A4.
This is the method:
public void actionPerformed(java.awt.event.ActionEvent e) {
// Get a PrinterJob
java.awt.print.PrinterJob job =
java.awt.print.PrinterJob.getPrinterJob();
// Create a landscape page format
java.awt.print.PageFormat landscape = job.defaultPage(new
java.awt.print.PageFormat());
java.awt.print.PageFormat landscape1 = job.defaultPage();
java.awt.print.Paper pp = landscape.getPaper();
pp.setSize(841, 522); //A4
landscape.setPaper(pp);
landscape.setOrientation(java.awt.print.PageFormat.PORTRAIT);
// Set up a book
java.awt.print.Book bk = new java.awt.print.Book();
bk.append(new PaintCover(), landscape);
// Pass the book to the PrinterJob
job.setPageable(bk);
// Put up the dialog box
if (job.printDialog()) {
// Print the job if the user didn't cancel printing
try { job.print(); }
catch (Exception exc) { /* Handle Exception */
exc.printStackTrace(System.out);}
}
}
if you have any comments, or you know who can help me, let me know pls.
Saludos-Thanks and regards
Aleksander Matos
Analista Sistemas Junior
Sistemas & Servicios S. A.
S&S .... An IBM Company
Phone (511) 317-6753 Tie Line: 836-6753
e-mail [email protected]
You can read messages from the JAVA archive, unsubscribe from JAVA,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.