-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
None
-
beta
-
x86
-
windows_nt
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2035602 | 1.4.0 | Jennifer Godinez | P3 | Resolved | Fixed | beta |
If a printer supports custom paper sizes, in particular ones which are
much larger than any that correspond to a standard paper, the printout
is clipped.
I have attached a short piece of code which demonstrates the problem. If
the code is executed with jdk 1.2.2 I get the expected 66 inches of paper,
however if it is executed with jdk 1.3 I get only 41 1/2 inches of paper
even if I set the default page for the printer to the desired size (12"x66").
At this point I'm not sure how to proceed. We do not want to revert to
1.2.2 because of the "auto-scroll" bug and other performance reasons, but
we need to support large format printers.
The large format printer we are using is a HP DesignJet 2500CP.
Driver: hpltdrv1.dll v4.00
Also, there is nothing special about this particular size. It just happens
to correspond to 100 ft at 1/20 scale with some extra room for headers,
footers, and margins.
import java.awt.*;
import java.awt.print.*;
import java.awt.geom.*;
public class PlotterTester implements Pageable, Printable{
private static double PIXELS_PER_INCH = 72.0;
private PrinterJob printerJob;
private PageFormat pageFormat;
PlotterTester(){
printerJob = PrinterJob.getPrinterJob();
createPageFormat();
}
private void createPageFormat(){
pageFormat = new PageFormat();
Paper p = new Paper();
double width = 12.0*PIXELS_PER_INCH;
double height = 66.0*PIXELS_PER_INCH;
double ix = PIXELS_PER_INCH;
double iy = PIXELS_PER_INCH;
double iwidth = width - 2.0*PIXELS_PER_INCH;
double iheight = height - 2.0*PIXELS_PER_INCH;
p.setSize(width, height);
p.setImageableArea(ix, iy, iwidth, iheight);
pageFormat.setPaper(p);
}
public Printable getPrintable(int index){
return this;
}
public PageFormat getPageFormat(int index){
return pageFormat;
}
public int getNumberOfPages(){
return 1;
}
public void print(){
if(printerJob.printDialog()){
System.out.println("start printing");
try{
//pageFormat = printerJob.pageDialog(pageFormat);//new PageFormat());
//printerJob.validatePage(pageFormat);
printerJob.setPageable(this);
//printerJob.setPrintable(this, pageFormat);
printerJob.print();
}catch(Exception e){e.printStackTrace();}
}
System.out.println("done printing");
}
public int print(Graphics g, PageFormat pf, int pageIndex){
//System.out.println(""+pageIndex);
if(pageIndex == 0){
Graphics2D g2 = (Graphics2D)g;
Rectangle2D r = new Rectangle2D.Double(pf.getImageableX(), pf.getImageableY(), pf.getImageableWidth(), pf.getImageableHeight());
g2.setStroke(new BasicStroke(5.0f));
g2.draw(r);
return PAGE_EXISTS;
}else{
return NO_SUCH_PAGE;
}
}
public static void main(String[] args){
PlotterTester pt = new PlotterTester();
pt.print();
try{
System.in.read();
}catch(Exception e){}
System.exit(0);
}
}
much larger than any that correspond to a standard paper, the printout
is clipped.
I have attached a short piece of code which demonstrates the problem. If
the code is executed with jdk 1.2.2 I get the expected 66 inches of paper,
however if it is executed with jdk 1.3 I get only 41 1/2 inches of paper
even if I set the default page for the printer to the desired size (12"x66").
At this point I'm not sure how to proceed. We do not want to revert to
1.2.2 because of the "auto-scroll" bug and other performance reasons, but
we need to support large format printers.
The large format printer we are using is a HP DesignJet 2500CP.
Driver: hpltdrv1.dll v4.00
Also, there is nothing special about this particular size. It just happens
to correspond to 100 ft at 1/20 scale with some extra room for headers,
footers, and margins.
import java.awt.*;
import java.awt.print.*;
import java.awt.geom.*;
public class PlotterTester implements Pageable, Printable{
private static double PIXELS_PER_INCH = 72.0;
private PrinterJob printerJob;
private PageFormat pageFormat;
PlotterTester(){
printerJob = PrinterJob.getPrinterJob();
createPageFormat();
}
private void createPageFormat(){
pageFormat = new PageFormat();
Paper p = new Paper();
double width = 12.0*PIXELS_PER_INCH;
double height = 66.0*PIXELS_PER_INCH;
double ix = PIXELS_PER_INCH;
double iy = PIXELS_PER_INCH;
double iwidth = width - 2.0*PIXELS_PER_INCH;
double iheight = height - 2.0*PIXELS_PER_INCH;
p.setSize(width, height);
p.setImageableArea(ix, iy, iwidth, iheight);
pageFormat.setPaper(p);
}
public Printable getPrintable(int index){
return this;
}
public PageFormat getPageFormat(int index){
return pageFormat;
}
public int getNumberOfPages(){
return 1;
}
public void print(){
if(printerJob.printDialog()){
System.out.println("start printing");
try{
//pageFormat = printerJob.pageDialog(pageFormat);//new PageFormat());
//printerJob.validatePage(pageFormat);
printerJob.setPageable(this);
//printerJob.setPrintable(this, pageFormat);
printerJob.print();
}catch(Exception e){e.printStackTrace();}
}
System.out.println("done printing");
}
public int print(Graphics g, PageFormat pf, int pageIndex){
//System.out.println(""+pageIndex);
if(pageIndex == 0){
Graphics2D g2 = (Graphics2D)g;
Rectangle2D r = new Rectangle2D.Double(pf.getImageableX(), pf.getImageableY(), pf.getImageableWidth(), pf.getImageableHeight());
g2.setStroke(new BasicStroke(5.0f));
g2.draw(r);
return PAGE_EXISTS;
}else{
return NO_SUCH_PAGE;
}
}
public static void main(String[] args){
PlotterTester pt = new PlotterTester();
pt.print();
try{
System.in.read();
}catch(Exception e){}
System.exit(0);
}
}
- backported by
-
JDK-2035602 Java 2D printing : custom paper sizes not working properly
-
- Resolved
-