Java is not able to read landscape-oriented paper sizes (like Ledger) in PPD files
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
icedtea-java7 (Ubuntu) |
New
|
Medium
|
Unassigned | ||
openjdk-6 (Ubuntu) |
New
|
Medium
|
Unassigned | ||
sun-java6 (Ubuntu) |
New
|
Medium
|
Unassigned |
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>>setpagede
*PageSize Legal/US Legal: "<</PageSize[612 1008]/ImagingBBox null>>setpagede
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.
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.
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:
$ sudo sed -i 's/1224 792/792 1224/g' /etc/cups/
$ java DumpPrintInfo
...
ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: cups 1.4.3-1ubuntu1.3
ProcVersionSign
Uname: Linux 2.6.32-25-generic x86_64
NonfreeKernelMo
Architecture: amd64
Date: Thu Dec 9 13:00:36 2010
InstallationMedia: Kubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100427)
Lpstat: device for Virtual_
MachineType: Hewlett-Packard HP Pavilion dv3 Notebook PC
Papersize: a4
PpdFiles: Virtual_
ProcCmdLine: BOOT_IMAGE=
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.
dmi.board.name: 306D
dmi.board.vendor: Compal
dmi.board.version: 22.23
dmi.chassis.type: 10
dmi.chassis.vendor: Compal
dmi.chassis.
dmi.modalias: dmi:bvnHewlett-
dmi.product.name: HP Pavilion dv3 Notebook PC
dmi.product.
dmi.sys.vendor: Hewlett-Packard
tags: | added: patch |
summary: |
- 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 |
Changed in sun-java6 (Ubuntu): | |
importance: | Undecided → Medium |
tags: |
added: patch-rejected removed: patch |
Added patch for postscript.ppd. Note that this doesn't fix the entire problem, as every PPD with the same line is affected. On my system there are 238 of those.
A PPD can be automatically patched with:
$ sed -i 's/1224 792/792 1224/g' file.ppd