Printing gets partial results

J

John Schank

Hi there,

I have a Java PrinterJob that is printing a printable object. The pages
are a header with an image and two lines of text, plus a table header.
The middle portion is data from the cells of a table. And there is a
few lines of footer text. Originally I tried scaling the graphics
object, and telling the table to print, but after a few pages, the
table would stop printing. So I converted to code to manually get the
data from the table and print it using DrawString commands on the
graphics context. All of my layout code seems correct because most
pages will print correctly (all pages are identically generated, they
just print data from different portions of the table, on different
pages)

The problem is that on any job larger than a page, one page will stop
rendering often in the middle of a line, and the rest of that page will
not render to the printer. It is actually kind of weird behaviour
because if I run the same job again (regenerating it from scratch - not
reusing the printer job). Then a different page will be the problematic
page and cease rendering.

Usually this is only 1 or 2 pages. Even on a job of 170 pages. It is
exactly enough to make the whole thing useless. Because every job, no
matter how small will have one page that fails to render. (except a
single page job. That works)

It is as though the page needs to be "flushed" and the engine is giving
up on the page for some unknown reason.

It could be a threading issue, but I've tried running the whole shebang
(getting the print service, popping the dialog, and printing) on the
EDT. And I've tried running portions in a separate thread. (Ideally,
this would ALL happen in a separate thread so that other portions of
the app aren't blocked). None of those attempts made much difference.
(Some attempts had worse results than others. But NOTHING will make the
whole job print cleanly)

I've also tried using the PrintService method as well as the printerjob
method. Both end up with the same results

I have no idea why this is happening. Does anyone out there have any
suggestions at all?

Thanks for bearing with this long message,
John Schank

BTW, I'm testing this by printing to a PDF printer, so as not to waste
paper. But I don't think that is a critical element.
 
C

Chris Uppal

John said:
I have no idea why this is happening. Does anyone out there have any
suggestions at all?

Might help to know what OS you're running on. Also which version of Java/JRE.

(But whatever, /I/ won't be able to help -- I am happily ignorant about Java
printing ;-).

-- chris
 
Z

zero

The problem is that on any job larger than a page, one page will stop
rendering often in the middle of a line, and the rest of that page will
not render to the printer. It is actually kind of weird behaviour
because if I run the same job again (regenerating it from scratch - not
reusing the printer job). Then a different page will be the problematic
page and cease rendering.

I have very little experience with java printing, so these are just some
random thoughts. Have you tried different testing with a different print
driver (there are several drivers out there that will print to an image
file, to help with the not wasting paper thing), and on a different
machine? My first thought was that it sounds like an OS/hardware/driver
problem.

If the problem happens on all configurations it's most likely your code.
It could also be a bug in the JRE, but that's less likely. Posting some
code here would give other people a chance to look it through.
 
J

Jeffrey H. Coffield

John Schank wrote:




I have spent a great deal of time trying to get Java printing under the
1.5 jvm (both linux & windows) to work and I finally gave up and
directly generate a postscript document. I not only had problems like
you, but also never got the page to print even close to right on 11x17
or 12x18 paper. Rotating the page to landscape was an even greater disaster.

Java printing is one of the (few) areas where I feel the developers just
don't get it.

Jeff C.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,114
Latest member
GlucoPremiumReview
Top