Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

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

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

972 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