Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : java version "1.7.0-ea" Java(TM) SE Runtime Environment (build 1.7.0-ea-b87) Java HotSpot(TM) 64-Bit Server VM (build 18.0-b01, mixed mode) ADDITIONAL OS VERSION INFORMATION : Linux ubuntu01 2.6.24-25-generic #1 SMP Tue Oct 20 06:49:12 UTC 2009 x86_64 GNU/Linux A DESCRIPTION OF THE PROBLEM : NPE while printing under linux STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Launch test case under linux EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - A page should be printed ACTUAL - Working under Windows (jdk 1.6 and jdk1.7ea) Working under Linux (jdk 1.6) Fails under Linux (jdk1.7ea) ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.lang.NullPointerException at sun.awt.PlatformFont.makeMultiCharsetString(PlatformFont.java:154) at sun.awt.PlatformFont.makeMultiCharsetString(PlatformFont.java:114) at sun.print.PSPrinterJob.textOut(PSPrinterJob.java:1201) at sun.print.PSPathGraphics.drawString(PSPathGraphics.java:228) at sun.print.PSPathGraphics.drawString(PSPathGraphics.java:140) at sun.print.PSPathGraphics.drawString(PSPathGraphics.java:114) at Print2DGraphics.print(Print2DGraphics.java:73) at sun.print.RasterPrinterJob.printPage(RasterPrinterJob.java:2008) at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1457) at sun.print.UnixPrintJob.printableJob(UnixPrintJob.java:636) at sun.print.UnixPrintJob.print(UnixPrintJob.java:493) at Print2DGraphics.<init>(Print2DGraphics.java:51) at Print2DGraphics.main(Print2DGraphics.java:82) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.print.PageFormat; import java.awt.print.Printable; import javax.print.Doc; import javax.print.DocFlavor; import javax.print.DocPrintJob; import javax.print.PrintException; import javax.print.PrintService; import javax.print.PrintServiceLookup; import javax.print.SimpleDoc; import javax.print.attribute.HashPrintRequestAttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.JobName; import javax.print.attribute.standard.OrientationRequested; public class Print2DGraphics implements Printable { public Print2DGraphics() { /* Construct the print request specification. * The print data is a Printable object. * the request additonally specifies a job name, 2 copies, and * landscape orientation of the media. */ DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(OrientationRequested.LANDSCAPE); aset.add(new Copies(2)); aset.add(new JobName("My job", null)); /* locate a print service that can handle the request */ PrintService service = PrintServiceLookup.lookupDefaultPrintService(); if (service != null) { System.out.println("Selected printer: " + service.getName()); /* create a print job for the chosen service */ DocPrintJob pj = service.createPrintJob(); try { /* * Create a Doc object to hold the print data. */ Doc doc = new SimpleDoc(this, flavor, null); /* print the doc as specified */ pj.print(doc, aset); /* * Do not explicitly call System.exit() when print returns. * Printing can be asynchronous so may be executing in a * separate thread. * If you want to explicitly exit the VM, use a print job * listener to be notified when it is safe to do so. */ } catch (PrintException e) { System.err.println(e); } } } public int print(Graphics g,PageFormat pf,int pageIndex) { if (pageIndex == 0) { Graphics2D g2d= (Graphics2D)g; g2d.translate(pf.getImageableX(), pf.getImageableY()); g2d.setColor(Color.black); g2d.drawString("example string", 250, 250); g2d.fillRect(0, 0, 200, 200); return Printable.PAGE_EXISTS; } else { return Printable.NO_SUCH_PAGE; } } public static void main(String arg[]) { Print2DGraphics sp = new Print2DGraphics(); } } ---------- END SOURCE ---------- adding case name for qare linking: java/awt/print/PageFormat/SetOrient.html java/awt/print/PrinterJob/InitToBlack.html java/awt/PrintJob/Text/PrintText.java java/awt/PrintJob/Text/PrintText2.java java/awt/PrintJob/Text/StringWidth.java java/awt/print/PageFormat/Orient.java java/awt/print/PrinterJob/CustomFont/CustomFont.java java/awt/print/PrinterJob/DrawStringMethods.java java/awt/print/PrinterJob/PrintDialogCancel.java java/awt/print/PrinterJob/PrintTextLayout.java java/awt/print/PrinterJob/ThinLines.java sun/java2d/GdiRendering/GdiBlitOffscreenTest.java java/awt/print/PrinterJob/ScaledText/ScaledText.java java/awt/print/PrinterJob/Cancel/PrinterJobCancel.java
|