Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2002-04-04
3
Medium Priority
?
208 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

721 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