public PageFormat createPageFormat() {
		PageFormat format = new PageFormat();
		PageOrientation orientation = getPageOrientation();
		double[] size = getPaperSize(LengthUnits.PT);
		double[] margins = getPaperMargins(LengthUnits.PT);
		Paper paper = new Paper();

		if (orientation == PageOrientation.PORTRAIT) {
			format.setOrientation(PageFormat.PORTRAIT);
		} else if (orientation == PageOrientation.LANDSCAPE) {
			format.setOrientation(PageFormat.LANDSCAPE);
		} else if (orientation == PageOrientation.REVERSE_PORTRAIT) {
			// REVERSE_PORTRAIT doesn't exist in the old PageFormat class
			format.setOrientation(PageFormat.PORTRAIT);
		} else if (orientation == PageOrientation.REVERSE_LANDSCAPE) {
			format.setOrientation(PageFormat.REVERSE_LANDSCAPE);
		}
		paper.setSize(size[0], size[1]);
		paper.setImageableArea(margins[1], margins[0], size[0] - (margins[1] + margins[3]), size[1] - (margins[0] + margins[2]));
		format.setPaper(paper);
		return format;
	}