views:

46

answers:

1

The have a generated post script file and i want to print using it. How can it be achieved in java either using java print API or awt. Is it possible?

+1  A: 

Complicated. Does your printer(s) support PostScript? Is it networked? If so, most networked printers can talk LPR and you can shove the file over as-is. On Windows, you could also stream the file as-is to the lpt1: mapped port via something like NET USE LPT1: \\[Computer Name]\Printer /PERSISTENT:YES.

If you're on a server and you do lots of PostScript handling and your printer infrastructure supports it, I would very much look into the LPR protocol. I've written several LPR/LPD management functions in Java to handle printer jobs, so definetely know it can be done with some relative ease.

http://tools.ietf.org/pdf/rfc1179.pdf

Xepoch
Printer used: Canon iR5050 PCL6
Rachel
Then you'll need to transform PS->PCL. I'd write a web service to perform the same.
Xepoch
If i generate a PCL file instead of PS file so should i stream the PCL file to lpt1?
Rachel
Yes, PCL should be able to be streamed/copied over to said port without issue (or at least every other PCL printer with which I've worked). Ghostscript does a fantastic job of interpreting PostScript and transforming to other languages (e.g. PCL). If this is a commercial venture, remember there are a LOT of advantages to PostScript in terms of document management, and a lot of advantages to LPD for print queuing vs. direct byte copying.
Xepoch
BTW, that printer should easily support PostScript, should not need to worry about PCL.
Xepoch
Oh is it. I was not sure if Canon iR5050 PCL6 can support PS. Be it PCL or PS docflavor, i am unable to get the printer instance using the doc flavor niether as PCL or PS using the code below. What could be the issue. DocFlavor psFlavor = DocFlavor.INPUT_STREAM.POSTSCRIPT; PrintService[] services = PrintServiceLookup.lookupPrintServices(psFlavor, null);
Rachel
Could you please share a sample java code to print using a PS script. I tried hard to get it but in vain.
Rachel
Yep, http://www.canonir5050.com/ looks like `%!PS` magic is supported. The code I'm discussing using LPR is not über-difficult, but nor is it trivial. Contact me via my profile and I can share some additional info over email (it is commercial otherwise I'd post whatever snippets I could here).
Xepoch
Thank you. Sure.
Rachel
With Canon iR5050 PCL6, I tried to use the basic print feature of javax print. I was able to print contents from a txt file but i am unable to modify the no. of copies, orientation etc. even when setting the PrintRequestAttributes. Is it a printer specific issue? Is there any way to get around it?
Rachel
Have you tried FTP'ing the PostScript file to the Canon?
Xepoch
No. When i tried to fetch the supported docflavors of the printer using java print API, it does not specify PS or PCL.
Rachel
I'm talking about sending via FTP protocol, not the print API.
Xepoch
Rachel