473,387 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

very slow printing with java.​awt.​print.​PrinterJob

Hi guys,

currently I'm encountering a strange behavior while using the PrinterJob class.

I've got a little program printing some pages. Most of the time the printer does its job as it should. But sometimes it takes minutes printing a page which was printed before in seconds.
It's absolutely random and not reproducible.

Following, the gist of the used code.
Where the Printable is a simple class implementing Printable and printing some text using Graphics.


Expand|Select|Wrap|Line Numbers
  1.     private void createPrinterJob(...) {
  2.         try {
  3.             Printable gp = new Printable( ... );
  4.             PrinterJob pjob = PrinterJob.getPrinterJob();
  5.             if (pjob.printDialog() == false) {
  6.                 return;
  7.             }
  8.             pjob.setPrintable(gp);
  9.             pjob.print();
  10.         } catch (PrinterException ex) {
  11.             ex.printStackTrace();
  12.         }
  13.     }
  14.  
I would be very glad if somebody ran across the same problem before and knows how to fix it.
Dec 22 '09 #1
1 5155
The call to setPrintable() is the culprit. I have written several printing routines, and they all call setPrintable(). If you take that out, it will process very quickly (but will not print). I have not found any way to speed this up.
Jul 23 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Rami | last post by:
Hello All, We have a java application including applets, servlets and ejbs. Users can get reports and print them directly from applets. Our print methods uses PrinterJob and Graphics2d, imports...
5
by: java_helloworld | last post by:
I am trying to print from an applet using the Java Print API. If I run the applet on appletviewer then things work fine i.e. I am able to get the print out. If I run the applet on a browser then...
4
by: jodi | last post by:
Hi, I am really newbie in Java I need to build an applet that prints a text, but, it can not roll the page I mean, when I print like "TEST ONE TEST TWOO TEST THREEE" the printer can not roll...
4
epots9
by: epots9 | last post by:
I have no clue how to print, but i have this: PrinterJob print = PrinterJob.getPrinterJob(); boolean okToPrint = print.printDialog(); if(okToPrint) { ...
1
by: rajarameshchint | last post by:
import java.util.*; import java.awt.*; import javax.swing.*; import javax.swing.event.*; import java.awt.event.*; import java.awt.print.*; public class sd7 extends JFrame implements...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.