6601097: Margins are not reset to hardware margins when width/height is 0 or -ve alongwith x, y

Reviewed-by: prr, jdv
This commit is contained in:
Prasanta Sadhukhan 2016-06-23 16:46:13 +05:30
parent 69128416e4
commit 1d8080cca9
2 changed files with 55 additions and 9 deletions

View file

@ -683,7 +683,21 @@ public abstract class RasterPrinterJob extends PrinterJob {
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));