public PageFormat getPageFormat(final int pageIndex) {
if (pageIndex >= this.pageList.size()) {
return null;
}
final Page page = this.pageList.get(pageIndex);
final PageFormat pageFormat = new PageFormat();
final Paper paper = new Paper();
final double width = toPoints(page.getWidth());
final double height = toPoints(page.getHeight());
// if the width is greater than the height assume lanscape mode
// and swap the width and height values in the paper format
if (width > height) {
paper.setImageableArea(0, 0, height, width);