Solved

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

Posted on 2002-04-04
3
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 video teaches viewers about errors in exception handling.
Suggested Courses

617 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