1
votes

when printing with Java, one can select the media tray (within PrintRequestAttributeSet). Then one can pass this setting to a printjob and have one's document printed to the given tray.

My question is now: can I somehow specify that the first page is printed to one tray and the second one to another tray within one print job?

I'm reluctant to creating two separate print jobs, because my usage scenario is a mass-print, of say 1000 documents. Each document has some pages going to tray 1 and some pages going to tray 2. If I have to create a new print job on each switch of trays, I would end up with several thousands of separate print jobs and I'm afraid of all sorts of print-spooler overruns and system crashes. Thus my preference to somehow sneak those "switches of tray" into one print job.

I'm pretty sure that it can be sone somehow, but didn't succeed so far.

I thought about creating those thousands of PrinterJobs, but having them print to a StreamPrintService (instead of an actual print service), thus capturing the switches of tray along with the actual printing data. Then I was planning to concatenate the results of those single "virtual" prints and send it all to a real printer in one real print job.

However, with java 1.6 there seems to be only one StreamPrintService, which can only output postscript. So: is there a way to capture the raw, native output from a native printer driver (using java)? Does it seem practical to you to concatenate that output and send it to the printer, in order to solve my problem?

I would be glad, also about comments regarding only parts of the problem..

1
What makes you "pretty sure" that this is possible? Frankly, I don't think this will ever work.Matthijs Bierman

1 Answers

1
votes

By adding a "Destination" attribute to one's print attribute set, the print can be redirected to a local file. That file contains the printjob in whatever language the actual printer's driver uses to talk in. In my case, I ended up with postscript files.

I created two postscript files, each printing from a different tray and then send their concatenation to the printer. And it worked :-) ! I switched of the printer to verify that there is only one printjob and I wrote some numbers on the paper in the those trays. So I guess I can be sure that it's not only wishful thinking ;-).

However, I think I won't pursue this topic in depth, because

  1. I'm not a printing guru and have my doubts that this approach works every case.

  2. For our customer, the whole thing is a nice-to-have at this time, so there won't be a budget to reasearch further on the circumstances under which this little idea works