? PageFormat.REVERSE_LANDSCAPE
: PageFormat.PORTRAIT));
}
Paper paper = new Paper();
MediaSize size = MediaSize.getMediaSizeForName(
newattrs.containsKey(Media.class)
&& (newattrs.get(Media.class).getClass().
isAssignableFrom(MediaSizeName.class))
? (MediaSizeName)newattrs.get(Media.class)
: MediaSizeName.ISO_A4);
paper.setSize(size.getX(Size2DSyntax.INCH) * 72.0,
size.getY(Size2DSyntax.INCH) * 72.0);
MediaMargins mm;
if (newattrs.containsKey(MediaMargins.class)) {
mm = (MediaMargins) newattrs.get(MediaMargins.class);
} else if(newattrs.containsKey(MediaPrintableArea.class)) {
mm = new MediaMargins(size,
(MediaPrintableArea) attrs.get(MediaPrintableArea.class));
} else {
mm = new MediaMargins(25.4F, 25.4F, 25.4F, 25.4F, MediaMargins.MM);
}
paper.setImageableArea(mm.getX1(MediaMargins.INCH) * 72.0,
mm.getY1(MediaMargins.INCH) * 72.0,
(size.getX(Size2DSyntax.INCH) - mm.getX1(MediaMargins.INCH) -
mm.getX2(MediaMargins.INCH)) * 72.0,
(size.getY(Size2DSyntax.INCH) - mm.getY1(MediaMargins.INCH) -
mm.getY2(MediaMargins.INCH)) * 72.0 );
pf.setPaper(paper);
return pf;
}