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

Bug #688062 reported by Vadim Troshchinskiy
This bug affects 1 person
Affects Status Importance Assigned to Milestone
icedtea-java7 (Ubuntu)
openjdk-6 (Ubuntu)
sun-java6 (Ubuntu)

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.


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

Only one paper type will be listed for the PDF printer:
                class javax.print.attribute.standard.Media
                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

ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: cups 1.4.3-1ubuntu1.3
ProcVersionSignature: Ubuntu 2.6.32-25.45-generic
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
 PATH=(custom, user)
SourcePackage: cups 04/21/2009
dmi.bios.vendor: Hewlett-Packard
dmi.bios.version: F.06
dmi.board.asset.tag: Base Board Asset Tag 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: HP Pavilion dv3 Notebook PC
dmi.product.version: F.06
dmi.sys.vendor: Hewlett-Packard

Revision history for this message
Vadim Troshchinskiy (vtroshchinskiy) wrote :
Revision history for this message
Vadim Troshchinskiy (vtroshchinskiy) wrote :
Revision history for this message
Vadim Troshchinskiy (vtroshchinskiy) wrote :

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

tags: added: patch
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

The Ledger size is correctly defined. Ledger is 17x11 inches, landscape format. The size you make out of it is Tabloid, 11x17 inches, portrait format. See, page 191 and 192 and also Tabloid is probably already available in these PPD files.

The bug is in the JRE. The PPD specs do not require the width of the paper being smaller than the height. The JRE must be able to read paper sizes which are defined in Landscape orientation.

affects: cups (Ubuntu) → openjdk-6 (Ubuntu)
Changed in openjdk-6 (Ubuntu):
importance: Undecided → Medium
Changed in icedtea-java7 (Ubuntu):
importance: Undecided → Medium
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
Revision history for this message
Vadim Troshchinskiy (vtroshchinskiy) wrote :

Okay, that is interesting.

There's a simple check for this in openjdk6, I will make a patch for removing it after I make sure nothing is going to go wrong elsewhere in the code if X > Y doesn't hold true.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.