← Back to team overview

openjdk team mailing list archive

[Bug 688062] Re: Java is not able to read landscape-oriented paper sizes (like Ledger) in PPD files

 

** Summary changed:

- Bad definition of Ledger paper size in postscript.ppd and derived PPDs breaks Java applications
+ Java is not able to read landscape-oriented paper sizes (like Ledger) in PPD files

** Also affects: sun-java6 (Ubuntu)
   Importance: Undecided
       Status: New

** Changed in: sun-java6 (Ubuntu)
   Importance: Undecided => Medium

** Tags added: patch-rejected
** Tags removed: patch

-- 
You received this bug notification because you are a member of OpenJDK,
which is subscribed to openjdk-6 in ubuntu.
https://bugs.launchpad.net/bugs/688062

Title:
  Java is not able to read landscape-oriented paper sizes (like Ledger) in PPD files

Status in “icedtea-java7” package in Ubuntu:
  New
Status in “openjdk-6” package in Ubuntu:
  New
Status in “sun-java6” package in Ubuntu:
  New

Bug description:
  Binary package hint: cups

The Ledger paper size is incorrectly defined in many printers' PPDs. This causes significant printing problems in Java applications.

The Ledger paper size is defined as follows. For comparison the Legal size is included as well:

*PageSize Ledger/Ledger: "<</PageSize[1224 792]/ImagingBBox null>>setpagedevice"                                                                                                                
*PageSize Legal/US Legal: "<</PageSize[612 1008]/ImagingBBox null>>setpagedevice"

Notice how in the Ledger case, the width is specified as larger than the height. This is the only such entry in the entire file. 

When the JRE parses the PPD to find paper sizes, it chokes on that entry and raises an exception:

IPPPrintService>>  error creating CUPSPrinter e=java.lang.IllegalArgumentException: X dimension > Y dimension

This exception is normally silently ignored. It can be seen by enabling debugging with the following code. Note this is a proprietary API and not guaranteed to work on all JDK versions. It was tested on openjdk-6-jre 6b09-0ubuntu2.

sun.print.IPPPrintService.debugPrint = true;

When this happens, parsing page sizes is aborted, and an empty list of paper sizes results. The JRE then adds a single entry corresponding to the default paper size on the system. For instance on US systems the only paper size added is Letter, and A4 on european ones. This results in the inability to print anything that doesn't use the default paper size.

This bug is in the postscript.ppd file, which has extended to many other printers. A trivial way of testing it is installing cups-pdf, which carries a PPD with the same bug. On my system, "grep -r '1224 792' /usr/share/ppd | grep PageSize  | wc -l" suggests 238 printers are affected.

Reproduction:

$ sudo apt-get install cups-pdf
$ javac DumpPrintInfo.java
$ java DumpPrintInfo

Only one paper type will be listed for the PDF printer:
                class javax.print.attribute.standard.Media
                        na-letter
                class javax.print.attribute.standard.NumberUp


$ sudo sed -i 's/1224 792/792 1224/g' /etc/cups/ppd/PDF.ppd

$ java DumpPrintInfo

                class javax.print.attribute.standard.Media
                        Custom
                        jis-b4
                        b
                        iso-c3
                        jis-b3
                        iso-a2
                        jis-b0
                        jis-b0
...

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: cups 1.4.3-1ubuntu1.3
ProcVersionSignature: Ubuntu 2.6.32-25.45-generic 2.6.32.21+drm33.7
Uname: Linux 2.6.32-25-generic x86_64
NonfreeKernelModules: nvidia
Architecture: amd64
Date: Thu Dec  9 13:00:36 2010
InstallationMedia: Kubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100427)
Lpstat: device for Virtual_PDF_Printer: cups-pdf:/
MachineType: Hewlett-Packard HP Pavilion dv3 Notebook PC
Papersize: a4
PpdFiles: Virtual_PDF_Printer: Generic CUPS-PDF Printer
ProcCmdLine: BOOT_IMAGE=/vmlinuz-2.6.32-25-generic root=/dev/mapper/hostname-root ro quiet splash
ProcEnviron:
 LANGUAGE=
 PATH=(custom, user)
 LANG=ru_RU.UTF-8
 SHELL=/bin/bash
SourcePackage: cups
dmi.bios.date: 04/21/2009
dmi.bios.vendor: Hewlett-Packard
dmi.bios.version: F.06
dmi.board.asset.tag: Base Board Asset Tag
dmi.board.name: 306D
dmi.board.vendor: Compal
dmi.board.version: 22.23
dmi.chassis.type: 10
dmi.chassis.vendor: Compal
dmi.chassis.version: N/A
dmi.modalias: dmi:bvnHewlett-Packard:bvrF.06:bd04/21/2009:svnHewlett-Packard:pnHPPaviliondv3NotebookPC:pvrF.06:rvnCompal:rn306D:rvr22.23:cvnCompal:ct10:cvrN/A:
dmi.product.name: HP Pavilion dv3 Notebook PC
dmi.product.version: F.06
dmi.sys.vendor: Hewlett-Packard