United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6506286 Printing under Linux doesn't work
JDK-6506286 : Printing under Linux doesn't work

Details
Type:
Bug
Submit Date:
2006-12-19
Status:
Closed
Updated Date:
2011-03-08
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
client-libs
OS:
linux
Sub-Component:
2d
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:
Relates:
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Linux bnb 2.6.18-1.2849.fc6 #1 SMP Fri Nov 10 12:45:28 EST 2006 i686 i686 i386 GNU/Linux
also Fedora core 5, Ubuntu 6.10

EXTRA RELEVANT SYSTEM CONFIGURATION :
Standard FC6, FC5 and Ubuntu installations

A DESCRIPTION OF THE PROBLEM :
Printing from java apps running under Java6 generate postscript file which includes command "/DeferredMediaSelection true". Currently used version of Ghostscript which is used under Linux to convert print jobs to formats used by non-postscript printers doesn't understand this command and produces the following error message:

ERROR: /configurationerror in --setpagedevice--
Additional information: [/DeferredMediaSelection true]
Operand stack:
   --dict:5/5(L)--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1   3   %oparray_pop   --nostringval--   --nostringval--   --nostringval--   --dict:1/2(L)--   --nostringval--   2   %dict_continue
Dictionary stack:
   --dict:1120/1686(ro)(G)--   --dict:0/20(G)--   --dict:130/200(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 3476
ESP Ghostscript 815.03: Unrecoverable error, exit code 1

This does not depends on the model of the printer, since printing to any non-postscript printer means preprocessing the file via Ghostscript. I don't have a proper PS printer to test if it works this way.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following program on Fedora core 6, 5 or Ubuntu 6.10 and choose any system printer in the dialog.

import javax.swing.*;
import java.awt.print.PrinterException;

public class SimplePrintingTest {

    public static void main(String[] args) {
        try {
            String[] columns = {"Col 1", "Col 2", "Col 3"};
            JTable table = new JTable(new String[][]{{"a", "b", "c"}, {"d", "e", "f"}}, columns);
            JFrame frame = new JFrame();
            frame.getContentPane().add(table);
            frame.pack();
            frame.setVisible(true);
            table.print();
        } catch (PrinterException e) {
            throw new RuntimeException(e);
        }
    }
}

For testing output to file can be chosen (but I have tested both by setting my system printer to print to a file).

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Pages to be printed normally like it happens with Java5
ACTUAL -
No pages are printed and the error above appears in the logs

ERROR MESSAGES/STACK TRACES THAT OCCUR :
ERROR: /configurationerror in --setpagedevice--
Additional information: [/DeferredMediaSelection true]
Operand stack:
   --dict:5/5(L)--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1   3   %oparray_pop   --nostringval--   --nostringval--   --nostringval--   --dict:1/2(L)--   --nostringval--   2   %dict_continue
Dictionary stack:
   --dict:1120/1686(ro)(G)--   --dict:0/20(G)--   --dict:130/200(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 3476
ESP Ghostscript 815.03: Unrecoverable error, exit code 1

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.print.PrinterException;

public class SimplePrintingTest {

    public static void main(String[] args) {
        try {
            String[] columns = {"Col 1", "Col 2", "Col 3"};
            JTable table = new JTable(new String[][]{{"a", "b", "c"}, {"d", "e", "f"}}, columns);
            JFrame frame = new JFrame();
            frame.getContentPane().add(table);
            frame.pack();
            frame.setVisible(true);
            table.print();
        } catch (PrinterException e) {
            throw new RuntimeException(e);
        }
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
The only workaround currently is to print to file and manually remove the string:
"/DeferredMediaSelection true"
Then resubmit the file manually - this prints without a problem

Release Regression From : 5.0
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

                                    

Comments
EVALUATION

DeferredMediaSelection is a valid Postscript command.  Exactly the same problem is  seen in Wordperfect using Ghostscript 8.15 so this looks like a Ghostscript bug.  Closing as not a defect.
                                     
2007-01-09
EVALUATION

Fixed by adding a condition for sending DeferredMediaSelection command. It is now limited to postscript printers only.
                                     
2007-02-13



Hardware and Software, Engineered to Work Together