--- old/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java 2016-06-17 11:49:16.652874500 +0530 +++ new/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java 2016-06-17 11:49:15.915280800 +0530 @@ -683,7 +683,21 @@ float iw = (float)(page.getPaper().getImageableWidth()/DPI); float iy = (float)(page.getPaper().getImageableY()/DPI); float ih = (float)(page.getPaper().getImageableHeight()/DPI); - if (ix < 0) ix = 0f; if (iy < 0) iy = 0f; + + if (ix < 0) ix = 0; if (iy < 0) iy = 0; + if (iw <= 0) iw = (float)(page.getPaper().getWidth()/DPI) - (ix*2); + + // If iw is still negative, it means ix is too large to print + // anything inside printable area if we have to leave the same margin + // in the right side of paper so we go back to default mpa values + if (iw < 0) iw = 0; + + if (ih <= 0) ih = (float)(page.getPaper().getHeight()/DPI) - (iy*2); + + // If ih is still negative, it means iy is too large to print + // anything inside printable area if we have to leave the same margin + // in the bottom side of paper so we go back to default mpa values + if (ih < 0) ih = 0; try { pageAttributes.add(new MediaPrintableArea(ix, iy, iw, ih, MediaPrintableArea.INCH));