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

blank page when printing text file

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 8u25
    • client-libs
    • 2d
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
      Java HotSpot(TM) Client VM (build 25.25-b02, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      When trying print a simple text file, the result is a blank page.
      I've created a simple application that show the problem:
      https://github.com/brevleq/print-error
      This same program runs correctly in ubuntu 14.04.1 LTS

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a PrinterJob and show the print dialog.
      Select the printer and submit the print dialog.
      Create a DocFlavor of the type INPUT_STREAM.AUTOSENSE, load a text file in a SimpleDoc object.
      Find the printService, create a job and print the created doc.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Content of text file printed.
      ACTUAL -
      Blank page printed

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.print.PrinterJob;
      import javafx.stage.Stage;
      import javax.print.*;
      import javax.print.attribute.HashPrintRequestAttributeSet;
      import javax.print.attribute.PrintRequestAttributeSet;
      import javax.print.attribute.standard.Copies;
      import javax.print.attribute.standard.JobName;
      import java.util.Locale;

      public class PrintError extends Application {
      public static void main(String args[]) {
      launch(args);
      }
      public void start(Stage stage) throws PrintException {
      PrinterJob printerJob = PrinterJob.createPrinterJob();
      printerJob.showPrintDialog(stage);
      PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
      printRequestAttributeSet.add(new Copies(printerJob.getJobSettings().getCopies()));
      printRequestAttributeSet.add(new JobName("test", Locale.getDefault()));
      DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
      Doc mydoc = new SimpleDoc(ClassLoader.class.getResourceAsStream("/should-be-printed.txt"), flavor, null);
      DocPrintJob job = getPrintService(printerJob.getPrinter().getName()).createPrintJob();
      job.print(mydoc, printRequestAttributeSet);
      }
      private PrintService getPrintService(String name) {
      for (PrintService printService : java.awt.print.PrinterJob.lookupPrintServices()) {
      if (name.equalsIgnoreCase(printService.getName())) {
      return printService;
      }
      }
      return null;
      }
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: