Solved

Any fix in JDK1.2 for huge spool file size?

Posted on 2002-04-04
3
200 Views
Last Modified: 2010-03-31
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 I
need is to reduce the spool file size to somewhat
nearer to what other applications like Notepad/Textpad do.

The same problem was raised as a BUG and closed.
The application we develop is using IBM JDK1.2.
I know this problem is fixed in IBM JDK1.3.
But I searching for a fix in JDK1.2 itself, since
porting to IBM JDK1.3 is not in our plans now.

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.");
  }
 }
}

}

Thank you,
Lenin.

/*
Note: Printing was done on HP LaserJet 2100.
OS: Windows 2000 Professional Edition
*/

0
Comment
Question by:lenink
3 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 7932697
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
To be deleted and points refunded
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
0
 

Author Comment

by:lenink
ID: 7933398
I have no problem to delete this question. please go ahead.
mean i overcome this problem by writing a windows dll for printing and calling them using JNI.
thanks,
lenin.
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7984186
PAQ'd and points refunded

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now