Solved

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

Posted on 2002-04-04
3
201 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error with Java/Cache JDBC Classpath 2 31
JUnit 4 @Before and @BeforeClass differences 3 49
Java - Why doesn't this JFrame work 3 45
hibernate insert example 13 15
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

863 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

20 Experts available now in Live!

Get 1:1 Help Now