Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7107138

PSPrinterJob doesn't invoke lpr correctly on Linux

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • 9
    • 7
    • client-libs
    • 2d
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.7.0_147-icedtea"
      OpenJDK Runtime Environment (IcedTea7 2.0) (7~b147-2.0-1)
      OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Debian Wheezy 3.0.0-2-amd64 #1 SMP Fri Oct 7 20:48:45 UTC 2011 x86_64 GNU/Linux

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      The system is linked with a network printer (Brother filterHL5350DNLT).
      This printer is a ps-based printer and is configured in cups correctly (so the options like tray and duplex work when invoked through cups)

      A DESCRIPTION OF THE PROBLEM :
      The problem is that when I try to submit a printjob to the printer (described in additional config) I always get a message on the printer about "Incorrect size".
      When I invoke the printer, I always specify a tray - when I do not specify a tray, tray 1 is always used and the printing works.

      I've been debugging this issue for a long time and I came out at sun.print.PSPrinterJob.printExecCmd line 1553 where I could find the code: execCmd[n++] = new String(options);
      In the man-page for LPR I could find that options should be passed with the "-o" prefix (like done on line 1573 in the same method and also in UnixPrintJob does this correctly).
      But when this is solved, I believe there is still a problem because I couldn't find where "mOptions" (global var in PSPrintJob) is assigned to a correct value.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) take a printer that supports tray-based printing (if possible the same printer)
      2) create a small app that uses java.awt.print.PrinterJob to print something to tray 2
      3) run the app and validate the result

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      the printer takes a sheet from tray 2 and prints the content on it
      ACTUAL -
      the printer goes in error-mode with the message "incorrect size".

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
                  PrinterJob job = PrinterJob.getPrinterJob()
                  job.setPrintService(getPrintService());
                  job.setPrintable(printable);

                  MediaTray trayNumber = ... //one of the selected trays from the supported attributes list

                  PrintRequestAttributeSet reqAttrSet = new HashPrintRequestAttributeSet();
                  reqAttrSet.add(trayNumber);

                  job.print(reqAttrSet);
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      This workaround is only possible if you own the code that invokes the printjob:
      using DocPrintJob printerJob = printService.createPrintJob(); (so the print-features in javax.print)

      but this is impossible when using the a framework like JasperReports

            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: