Name: bsC130419 Date: 08/27/2001
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
/* Printing using Java Web Start.
* Jar file is unsigned.
* Access to PrintService is granted.
* Setting page orientation to 'LANDSCAPE' has absolutley no effect
* when calling the print method, orientation is always 'PORTRAIT'.
* This is a serious omission, as my program needs to print to landscape. This
* is serious enough that if this cannot be resolved then I must deploy my
* application in another way.
*
* The following program calles a print class, and writes the passed
* pageFormat orientation to the error stream. Setting the orientation to
* PageFormat.LANDSCAPE should result in "Landscape" being written to the
* error stream, but "Portrait" is the result. I presume that this is because
* my default paper settings are A4 portrait and that these are not overwritten
* by the call to PageFormat.setOrientation.
*
* Suggested solution: Add an argument to PrintService.print so that a
* PageFormat object can be passed.
*/
//Minimal program to reproduce the problem:
import javax.jnlp.*;
import java.awt.print.*;
import java.awt.*;
public class printTest {
public printTest() {
PrintService ps;
try {
ps = (PrintService)ServiceManager.lookup("javax.jnlp.PrintService");
}
catch (UnavailableServiceException e) {
ps = null;
}
if (ps != null) {
try {
PageFormat pf = ps.getDefaultPage();
pf.setOrientation(PageFormat.LANDSCAPE);
ps.print(new PageOne()); // Note: no argument to supply modified PageFormat
}
catch (Exception e) {
e.printStackTrace();
}
}
}
public static void main(String args[]) {
new printTest();
}
class PageOne implements Printable {
public int print(Graphics pg, PageFormat pageFormat, int pageIndex) throws PrinterException {
switch (pageFormat.getOrientation()) {
case PageFormat.LANDSCAPE : System.err.println("Landscape");
break;
case PageFormat.PORTRAIT : System.err.println("Portrait");
break;
case PageFormat.REVERSE_LANDSCAPE : System.err.println("Reverse landscape"); break;
}
return NO_SUCH_PAGE;
}
}
}
/**** Console Output: ****
* Java Web Start Console, started Thu Aug 23 10:25:53 GMT+01:00 2001
* Java 2 Runtime Environment: Version 1.3.0 by Sun Microsystems Inc.
* Portrait
*/
(Review ID: 130522)
======================================================================
- relates to
-
JDK-4908504 IllegalArgumentException thrown when printing on Solaris
-
- Closed
-