JDK-7067052 : Default printer media is ignored
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u26
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2011-07-14
  • Updated: 2015-01-21
  • Resolved: 2014-06-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u40Fixed 9 b24Fixed
Description
FULL PRODUCT VERSION :
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux  2.6.35.13-92.fc14.i686.PAE #1 SMP i686 i686 i386 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
cups-1.4.6-1.fc14.i686

A DESCRIPTION OF THE PROBLEM :
Regardless the default media setup in cups, java always uses the first media from ppd.

I sniffered the IPP communication between cups and java:
...Dmedia-defaultiso_a3_297x420mmDmedia-supportediso_a4_210x297mmDiso_a3_297x420mmD...
--> The default media is passed to java

When debugging the IPPPrintService, the  the defaultMediaIndex is 0 and the getAttMap contains only "media-default=media-default" (no valid media) which seems to be the problem.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Add cups printer (as default printer))
2. Change default media size in cups to A3
3. Run code-snippet (see below)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The default media size should be A3.
ACTUAL -
The default media is the first media.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.standard.Media;


public class TestPrinterDefaultMedia {

    public static void main(final String[] args) {
        final PrintService printService = PrintServiceLookup
                .lookupDefaultPrintService();

        // should return iso-a3
        System.out.println(printService.getDefaultAttributeValue(Media.class));
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Set default media at top position of media list in ppd file.