final double marginBottom = convertLengthToDouble
(rule.getPropertyCSSValue(BoxStyleKeys.MARGIN_BOTTOM), resolution);
if (width < height)
{
final Paper p = new Paper();
p.setSize(width, height);
p.setImageableArea(marginLeft, marginTop,
width - marginLeft - marginRight,
height - marginTop - marginBottom);
final PageFormat pageFormat = new PageFormat();
pageFormat.setPaper(p);
pageFormat.setOrientation(PageFormat.PORTRAIT);
return pageFormat;
}
else
{
final Paper p = new Paper();
p.setSize(height, width);
p.setImageableArea(marginLeft, marginTop,
width - marginLeft - marginRight,
height - marginTop - marginBottom);
final PageFormat pageFormat = new PageFormat();
pageFormat.setPaper(p);
pageFormat.setOrientation(PageFormat.LANDSCAPE);