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.
Xepoch
2010-10-28 20:22:38
Printer used: Canon iR5050 PCL6
Rachel
2010-10-28 20:37:03
Then you'll need to transform PS->PCL. I'd write a web service to perform the same.
Xepoch
2010-10-28 21:16:34
If i generate a PCL file instead of PS file so should i stream the PCL file to lpt1?
Rachel
2010-10-28 21:27:19
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
2010-10-28 22:13:42
BTW, that printer should easily support PostScript, should not need to worry about PCL.
Xepoch
2010-10-28 22:18:40
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
2010-10-28 22:46:30
Could you please share a sample java code to print using a PS script. I tried hard to get it but in vain.
Rachel
2010-10-28 22:49:39
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
2010-10-29 00:53:15
Thank you. Sure.
Rachel
2010-10-29 02:56:48
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
2010-10-29 03:08:42
Have you tried FTP'ing the PostScript file to the Canon?
Xepoch
2010-10-29 16:50:12
No. When i tried to fetch the supported docflavors of the printer using java print API, it does not specify PS or PCL.
Rachel
2010-10-29 18:08:09
I'm talking about sending via FTP protocol, not the print API.
Xepoch
2010-10-29 18:23:06
Rachel
2010-10-29 18:24:45