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

Cannot print to file under Windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.2
    • client-libs
    • 2d
    • x86
    • windows_xp



      Name: gm110360 Date: 12/12/2003


      FULL PRODUCT VERSION :
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

      FULL OS VERSION :
      Windows NT Version 4.0
      Windows 2000 [Version 5.00.2195]
      Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The print dialog displayed by ServiceUI.printDialog
      has a check box labeled "Print to File". It you
      check this box and then select "Print", a file
      selection dialog appears. The file you select here
      receives output that would otherwise be sent to a
      printer. This works just as expected under Linux.
      Under Windows, you can check "Print to File" and
      select a file name, but the job will be sent to
      the printer anyway.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the demo program included below.
      2. When the print dialog appears, select "Print to File".
      3. Select "Print".
      4. Select a file name.
      5. Try again under Linux for comparison.
         Everything works fine under SuSE 8.1, kernel 2.4.19, glibc 2.2.5

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Postscript output written to the selected file.
      ACTUAL -
      Postscript output sent to a printer.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.print.*;
      import javax.print.attribute.*;

      public class PrintDemo {

          public static void main( String args[] ) {

              String ps = // Some sample Postscript
                  "%!PS-Adobe-3.0\n" +
                  "/Courier findfont 14 scalefont setfont\n" +
                  "72 720 moveto\n" +
                  "(Hello World) show\n" +
                  "showpage\n";

              DocFlavor flavor = DocFlavor.BYTE_ARRAY.POSTSCRIPT;
              PrintRequestAttributeSet attrSet = new HashPrintRequestAttributeSet();

              try {
                  PrintService printer = ServiceUI.printDialog(
                      null,
                      400, 400,
                      PrintServiceLookup.lookupPrintServices( flavor, attrSet ),
                      PrintServiceLookup.lookupDefaultPrintService(),
                      flavor,
                      attrSet
                  );
                  DocPrintJob job = printer.createPrintJob();
                  SimpleDoc doc = new SimpleDoc( ps.getBytes(), flavor, null );
                  job.print( doc, attrSet );
              }
              catch ( Exception e ) {
                  System.err.println( e );
              }

              System.exit(0);
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Run application under Linux. :-)
      (Incident Review ID: 194227)
      ======================================================================

            jgodinez Jennifer Godinez (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: