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

Print using 1.2.2 drawString - gives huge spool jobs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.2.2
    • client-libs
    • None
    • 2d
    • unknown
    • windows_nt


      When printing from a Java application a number of pages containing text using drawString, the spooled file is eg. 10/25 Mb for 6 pages. This applies to PCL and postscript printer drivers.

      import java.awt.geom.*;
      import java.awt.event.ActionListener;
      import java.awt.event.ActionEvent;
      import java.awt.print.PrinterJob;
      import java.awt.event.*;
      import java.awt.*;
      import javax.swing.*;
      import java.awt.print.*;

      public class ShapesPrint extends JPanel implements Printable {

          public ShapesPrint() {
              PrinterJob printJob = PrinterJob.getPrinterJob();
              printJob.setPrintable(this);
              if (printJob.printDialog()) {
                  try {
                      printJob.print();
                  } catch (Exception ex) {
                      ex.printStackTrace();
                  }
              }
      }

      public int print(Graphics g, PageFormat pf, int pageIndex) {
              if (pageIndex <= 5 )
                      draw((Graphics2D) g);

              if (pageIndex >=6) {
                      return Printable.NO_SUCH_PAGE;
              }
              Dimension size = getSize();

              return Printable.PAGE_EXISTS;
      }

              public void draw(Graphics2D g) {

                      g.setColor(Color.black);
                      g.drawString("Testing in draw() again again again again again again again", 100, 80);
                      for(int counter = 100; counter < 700; counter = counter + 10)
                      g.drawString("Testing in draw() again again again again again again again", 100, counter);
              }

         public static void main(String s[]){
              new ShapesPrint();
          }
      }

            prr Philip Race
            mhosanee Matt Hosanee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: