Huge print spool file size.

Hi,
   When I print a page of text, the print queue box will
show 1.93MB of 2.06MB. It takes long time to print
a page of text. The same file when printed from other
application(Textpad) takes 26k and prints faster. Iam
currently preparing reports for our application, which we
develop using java. Printing multiple pages is a must and
doing so takes forever to print a 10 page report. All my
worries are reducing the spool file size to somewhat
nearer to what other applications like Notepad/Textpad
make.

The same problem was raised as a BUG and closed. I don't
know where the fix is.
URL : http://developer.java.sun.com/developer/
      bugParade/bugs/4186108.html

BUg Info:
**********
Bug Id           4186108
Votes            292
Synopsis         Printing more than 1 page using
                 PrinterJob.print(): long time, huge
                 files.
Category         java:classes_2D
ReportedAgainst  1.2RC1, 1.2RC2, 1.2fcs
Release          Fixed    
State            Closed, duplicate of 4227245
Related Bugs     4185668
Submit Date      Oct 30, 1998  

Description  
***********
    RFE 4227245 is changing the way text is printed in
the majority of cases so as to make vast reuction in
spool file sizes, particularly for PCL and PS printers.
    That RFE is partially implemented in Kestrel (Java 2
V1.3) Beta for "physical" fonts obtained via getAllFonts
() or getAvailableFontFanilyNames().The improvement for
logical fonts such as "dialog" is expected to be
implemented by Kestrel's FCS.

   
Here is my Sample Code
-----------------------
/* source for Printable implementation */

import java.awt.print.*;
import java.awt.*;
import java.util.*;

public class PrintTest implements Printable{

 public int print(Graphics g, PageFormat format, int
 pageIndex){

  int totalWidth = (int) format.getImageableWidth();
  int totalHeight = (int) format.getImageableHeight();
  int posX = (int) (format.getImageableX());
  int posY = (int) (format.getImageableY());
  posY += 10;
  FontMetrics fontMetrics =
   g.getFontMetrics(new Font("Courier", Font.PLAIN, 7));
  int charWidth = fontMetrics.stringWidth("W");
  int charHeight = fontMetrics.getHeight() + 1;
  int noOfLines = Math.round(totalHeight / charHeight);
  int noOfCharsPerLine = Math.round(totalWidth /
  charWidth);

  String printContent =
   "Test print message just to check the size of the
   spool file size.";
  g.setFont(new Font("Courier", Font.PLAIN, 7));
  if (pageIndex > 0) {
   for(int i=0;i< noOfLines;i++){
    g.drawString(printContent, posX, posY);
    posY += charHeight;
   }
  }
  return Printable.PAGE_EXISTS;
 }

 public static void main(String args[]){
  PrintTest printTest = new PrintTest();
  PrinterJob job = PrinterJob.getPrinterJob();
  PageFormat landscape = job.defaultPage();
  landscape.setOrientation(PageFormat.LANDSCAPE);

  Book bk = new Book();
  bk.append(printTest, landscape, 1);
  job.setPageable(bk);
  if (job.printDialog()) {
   try {
    job.print();
   }
   catch (Exception exc) {
    System.out.println("Could not print the document.");
   }
  }
 }

}

  Iam sure some one would have got a solution for this.
Thank you,
Lenin.

/*
Note: Printing was done on HP LaserJet 2100.
Java(TM) Plug-in: Version 1.3.1_02
Using JRE version 1.3.1_02 Java HotSpot(TM) Client VM
OS: Windows 2000 Professional Edition
*/

leninkAsked:
Who is Participating?
 
Venci75Commented:
I did the same.
0
 
Venci75Commented:
Hi lenink,
In this page (BUG report) the explanation is that this bug is fixed in the later varions of java and thus - it is closed.
I ran you example with java 1.3.1 under Windows and the spool file size was 27K. May you have to this version or hier.
0
 
leninkAuthor Commented:
Hi Venci75,
    Iam afraid, I have tested the example in JDK1.3, jdk 1.3.1_02 and j2sdk1.4. I could not find any difference. The spool file size was still 2.08MB. I tried printing a page using the Notepad application, which came along with J2sdk1.4. That make less spool file size (16kb).
    Whenever I run the sample code, I will get the print dialog. On clicking ok, a printer icon will appear in the system tray. I double click on that, and check for the size column. This is the way I check for the spool file size. How do you check your spool file size? Please correct me if Iam wrong.

Thank You,
Lenin.
0
 
leninkAuthor Commented:
Hi Venci75,
 I found out the problem, the spool file size is less than 20k. The problem was I had IBM JDK1.2 installed on my machine. When I removed that from my Path, it worked fine.
Iam happy to give you the points now.
Thanks,
Lenin.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.