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.
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.