-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
7u25, 8, 9
-
windows_7
FULL PRODUCT VERSION :
java version " 1.7.0_25 "
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
Microsoft Windows XP (full version not available)
EXTRA RELEVANT SYSTEM CONFIGURATION :
Printer Konica Minolta PagePro 1350W and 1200
A DESCRIPTION OF THE PROBLEM :
Several costumers that have Konica Minolta PagePro 1350W or Konica Minolta PagePro 1200 printers have reported, that prints from our application are printed in 200% scale (obviously not fitting to the page). Experiments with the printer have shown that no page format settings on the printer side are able to make a difference - even setting 50% scale on the printer side does not scale the print, it only crops it to half the page.
The application uses JasperReports library and prints flawlessly on about hundred installations, except those with the aforementioned printers.
Other programs such as Adobe Acrobat or Micrsoft Word print OK with the printers.
Tracking the issue further has shown, that the stretching behavior is independent of JasperReports and manifests whenever printing through java.awt.print.PrinterJob, but does not happen when printing through java.awt.PrintJob so it seems to be a JDK bug.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Print anything through java.awt.print.PrinterJob on the aforementioned printers. In the testcase below I am trying to print a line from top-left corner of the page to top-middle of the page.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
For both print executions I would expect to have a horizontal line printed from a point near the top left corner of the paper to the middle of the paper.
ACTUAL -
On most printers, the result is as expected, but on Konica Minolta 1350W, the first printing (using java.awt.print.PrinterJob) results in a thick line being printed from the top left corner across the whole paper.
The second printing works as expected.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.print.Book;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
/**
*
* @author MaCe
*/
public class PrintTest {
static Printable printable = new Printable() {
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
Graphics2D grx = (Graphics2D)graphics;
grx.drawLine(20,20, getPageWidth() / 2, 20);
return Printable.PAGE_EXISTS;
}
};
protected static int getPageWidth() {
//width of A4 in 1/72 of inches
return 595;
}
protected static int getPageHeight() {
//height of A4 in 1/72 of inches
return 842;
}
public static void main(String args[]) throws PrinterException {
Frame f = new Frame();
f.show();
//Build a buggy print job using PrinterJob class
PrinterJob printJob = PrinterJob.getPrinterJob();
/**
* Fix for bug ID 6255588 from Sun bug database
*/
try {
printJob.setPrintService(printJob.getPrintService());
} catch (PrinterException e) {
}
PageFormat pageFormat = printJob.defaultPage();
Paper paper = pageFormat.getPaper();
printJob.setJobName( " Buggy output " );
pageFormat.setOrientation(PageFormat.PORTRAIT);
paper.setSize(getPageWidth() , getPageHeight());
paper.setImageableArea(
0,
0, getPageWidth(), getPageHeight());
pageFormat.setPaper(paper);
Book book = new Book();
book.append(printable, pageFormat, 1);
printJob.setPageable(book);
if (printJob.printDialog()) {
printJob.print();
}
//Build a good print job using PrintJob class
PrintJob pjob = f.getToolkit().getPrintJob(f, " Good output " , null);
if (pjob!=null) {
Graphics g = pjob.getGraphics();
g.drawLine(20, 20, pjob.getPageDimension().width / 2, 20);
pjob.end();
}
System.exit(0);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Calling graphics.scale(0.5, 0.5) before starting the print.
java version " 1.7.0_25 "
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
Microsoft Windows XP (full version not available)
EXTRA RELEVANT SYSTEM CONFIGURATION :
Printer Konica Minolta PagePro 1350W and 1200
A DESCRIPTION OF THE PROBLEM :
Several costumers that have Konica Minolta PagePro 1350W or Konica Minolta PagePro 1200 printers have reported, that prints from our application are printed in 200% scale (obviously not fitting to the page). Experiments with the printer have shown that no page format settings on the printer side are able to make a difference - even setting 50% scale on the printer side does not scale the print, it only crops it to half the page.
The application uses JasperReports library and prints flawlessly on about hundred installations, except those with the aforementioned printers.
Other programs such as Adobe Acrobat or Micrsoft Word print OK with the printers.
Tracking the issue further has shown, that the stretching behavior is independent of JasperReports and manifests whenever printing through java.awt.print.PrinterJob, but does not happen when printing through java.awt.PrintJob so it seems to be a JDK bug.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Print anything through java.awt.print.PrinterJob on the aforementioned printers. In the testcase below I am trying to print a line from top-left corner of the page to top-middle of the page.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
For both print executions I would expect to have a horizontal line printed from a point near the top left corner of the paper to the middle of the paper.
ACTUAL -
On most printers, the result is as expected, but on Konica Minolta 1350W, the first printing (using java.awt.print.PrinterJob) results in a thick line being printed from the top left corner across the whole paper.
The second printing works as expected.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.print.Book;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
/**
*
* @author MaCe
*/
public class PrintTest {
static Printable printable = new Printable() {
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
Graphics2D grx = (Graphics2D)graphics;
grx.drawLine(20,20, getPageWidth() / 2, 20);
return Printable.PAGE_EXISTS;
}
};
protected static int getPageWidth() {
//width of A4 in 1/72 of inches
return 595;
}
protected static int getPageHeight() {
//height of A4 in 1/72 of inches
return 842;
}
public static void main(String args[]) throws PrinterException {
Frame f = new Frame();
f.show();
//Build a buggy print job using PrinterJob class
PrinterJob printJob = PrinterJob.getPrinterJob();
/**
* Fix for bug ID 6255588 from Sun bug database
*/
try {
printJob.setPrintService(printJob.getPrintService());
} catch (PrinterException e) {
}
PageFormat pageFormat = printJob.defaultPage();
Paper paper = pageFormat.getPaper();
printJob.setJobName( " Buggy output " );
pageFormat.setOrientation(PageFormat.PORTRAIT);
paper.setSize(getPageWidth() , getPageHeight());
paper.setImageableArea(
0,
0, getPageWidth(), getPageHeight());
pageFormat.setPaper(paper);
Book book = new Book();
book.append(printable, pageFormat, 1);
printJob.setPageable(book);
if (printJob.printDialog()) {
printJob.print();
}
//Build a good print job using PrintJob class
PrintJob pjob = f.getToolkit().getPrintJob(f, " Good output " , null);
if (pjob!=null) {
Graphics g = pjob.getGraphics();
g.drawLine(20, 20, pjob.getPageDimension().width / 2, 20);
pjob.end();
}
System.exit(0);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Calling graphics.scale(0.5, 0.5) before starting the print.