8165947: One more page printed before the test page with OpenJDK

8166259: One more banner page printed before the test page

Reviewed-by: prr, jdv
This commit is contained in:
Prasanta Sadhukhan 2016-09-26 14:47:41 +05:30
parent 8d81ec63b2
commit e319d259e6
2 changed files with 188 additions and 6 deletions

View file

@ -1282,12 +1282,6 @@ public abstract class RasterPrinterJob extends PrinterJob {
JobSheets jobSheets = (JobSheets)attributes.get(JobSheets.class);
if (jobSheets != null) {
noJobSheet = jobSheets == JobSheets.NONE;
} else {
JobSheets js = (JobSheets)getPrintService().
getDefaultAttributeValue(JobSheets.class);
if (js != null && js.equals(JobSheets.NONE)) {
noJobSheet = true;
}
}
JobName jobName = (JobName)attributes.get(JobName.class);
@ -1487,6 +1481,22 @@ public abstract class RasterPrinterJob extends PrinterJob {
throw new PrinterException("Printer is not accepting job.");
}
/*
* Check the default job-sheet value on underlying platform. If IPP
* reports job-sheets=none, then honour that and modify noJobSheet since
* by default, noJobSheet is false which mean jdk will print banner page.
* This is because if "attributes" is null (if user directly calls print()
* without specifying any attributes and without showing printdialog) then
* setAttribute will return without changing noJobSheet value.
* Also, we do this before setAttributes() call so as to allow the user
* to override this via explicitly adding JobSheets attributes to
* PrintRequestAttributeSet while calling print(attributes)
*/
JobSheets js = (JobSheets)psvc.getDefaultAttributeValue(JobSheets.class);
if (js != null && js.equals(JobSheets.NONE)) {
noJobSheet = true;
}
if ((psvc instanceof SunPrinterJobService) &&
((SunPrinterJobService)psvc).usesClass(getClass())) {
setAttributes(attributes);