1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
public static HashPrintRequestAttributeSet attribut = new HashPrintRequestAttributeSet();
public static Paper A4 = new Paper();
public static PageFormat pf = new PageFormat();
attribut.add(OrientationRequested.LANDSCAPE);
attribut.add(MediaSizeName.ISO_A4);
attribut.add(Chromaticity.MONOCHROME);
// set paper to A4
double cm = 72/2.54;
double w = 21*cm, h = 29.7*cm;
double top = cm, bottom = cm, left = 10, right = 10;
A4.setSize(w,h);
A4.setImageableArea(left, top, w-left-right, h-top-bottom);
pf.setPaper(A4);
PageFormat format = job.pageDialog(Centrale.attribut);
PageFormat format = job.pageDialog(attribut);
format.setPaper(A4)
if(job.printDialog(attribut)) {
job.print() |
Partager