public static double[] getPageMargins(PrintService service, PrintRequestAttributeSet set, LengthUnits units) {
		PageOrientation orientation = getPageOrientation(service, set);
		double[] margins = getPaperMargins(service, set, units);

		if (orientation == PageOrientation.LANDSCAPE) {
			return new double[] { margins[1], margins[2], margins[3], margins[0] };
		}
		if (orientation == PageOrientation.REVERSE_PORTRAIT) {
			return new double[] { margins[2], margins[3], margins[0], margins[1] };
		}
		if (orientation == PageOrientation.REVERSE_LANDSCAPE) {
			return new double[] { margins[3], margins[0], margins[1], margins[2] };
		}
		return margins;
	}