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

Use HTTP instead of lpr for sending print data in CUPS

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 5.0
    • client-libs
    • None
    • 2d
    • generic
    • generic

      This is related to bug 6520121. Problem occurs when we connect successfully to CUPS server but the path of lpr differs from the JDK assumption that it is in /usr/bin so we get an exception during printing. This can be avoided if we use HTTP for sending print data to printer.

      To reproduce, run the following program:

      import java.awt.*;
      import javax.print.*;
      import javax.print.attribute.*;
      import javax.print.attribute.standard.*;
      import java.awt.print.*;
      import java.io.*;

      public class HeadlessPrintingTest {

          public static void main(String[] args) {
              System.setProperty("java.awt.headless", "true");
              PrinterJob pj = PrinterJob.getPrinterJob();
              pj.setPrintable(new Printable() {
                  public int print(Graphics g, PageFormat pg, int pageIndex) {
                      Graphics2D g2d = (Graphics2D)g;
                      if (pageIndex > 2) {
                          return Printable.NO_SUCH_PAGE;
                      } else {
                          g2d.translate(pg.getImageableX(), pg.getImageableY());
                          g2d.setColor(Color.RED);
                          g2d.drawString("page " + pageIndex, 100, 100);
                          return Printable.PAGE_EXISTS;
                      }
                  }
              });

              try {
                  pj.print();
              } catch (Exception e) {
              e.printStackTrace();
              }
          }
      }

            psadhukhan Prasanta Sadhukhan
            jgodinez Jennifer Godinez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: