Has anyone managed to get cfprint working for Luce...
# lucee
j
Has anyone managed to get cfprint working for Lucee?
b
cfprint isn't supported by Lucee - https://docs.lucee.org/reference/tags/print.html
j
I should have been more clear. I understand that it cfprint does not work out of the box. Many things don't work, but people have gotten them added with plugins and custom code. For example I've got spreadsheets going again and cfspreadsheet isn't supported. That's why I am asking if anyone has gotten it working. Not out of the box, but custom Java and/or plugins.
d
Printing is such an uncommon task from CFML, that I'm not sure you'll get any step-by-step instructions. However, you can just look for any Java solution for printing and implement that. For example: https://stackoverflow.com/questions/6278405/connecting-and-printing-to-a-printer-in-java However, if I had to print from a web-based application, I'd assume it's probably being done on a large scale (like printing shipping labels or something). So instead of printing directly from CFML, I'd look into instead just writing the output you need printed to a file and then have an external job pick up those files and print it.
j
Yea I could see it being uncommon, but we've been using it in Adobe ColdFusion for years and just switched to Lucee last week. The site that prints is an internal site for my work place. We are printing USPS mailing paperwork, not labels but that was a good guess! We know we can do a separate application outside of CFML but we all wanted it to work through the site like before. Thanks for the link I will be looking into that.
d
@Jason Vicari I never tried printing from within web-based application, but the reason I'd explore an external queue for printing is that printing is often finicky. Printers get jammed, they go offline, etc. I'm not sure you want the CFML app to fail when the printer is having issues or have print jobs lost. If you just dump everything to a folder and have the files picked up and removed as they are printed, seems like you would reduce the likelihood of print jobs being lost.
j
After years, printing every day, we've never had an issue like you are describing. You admit you have no eyepiece with cfprint, then made up problems to make it look like a bad option. Printer jams, you clear jam and it continues printing. Printer is off, it waits till you turn it on, then prints. In my experience cfprint was very good, it wouldn't fail if their was printer issues. It was submitting to a print queue just like any other program would, so it didn't cause ColdFusion to fail. That being said I understand the need to print from a web server is probably rare, out of the dozens of sites I've built I only needed it on one of them, and had the option not been there I may very well have written an entirely different application, so I can see why it was left out of Lucee. My specific needs require it to print from multiple trays with different paper types, in the correct order while skipping some pages. And the pages are all within one PDF, so I specify printing page 1-5 on this paper then skip a few pages and 8-12 might be on a second paper and so on. Just submitting the PDF to a generic queue wont work, the queue would need to know which pages to print and on what type of paper so it pulls from the correct tray. I am not here looking to do this outside of Lucee, we already have a plan if we must go that route, so if you have no interest in helping me with Lucee, you don't need to waste any more time responding. Thanks for your feedback.
d
@Jason Vicari I apologize for offending you. It was certainly not my intention. > You admit you have no eyepiece with cfprint, then made up problems to make it look like a bad option. I prefixed my comment with the fact I've not had to deal with printing from a web application, specifically so my advice would be taken with a grain of salt. My comment was not intended to "make up" problems, but just problems I've seen with other application I have worked on that dealt with printing. If printing directly from within CFML works for you that's great! If you do need to explore the route of having an external process that monitors print jobs for you, one way you might be able to solve the issue of printing specific pages is generating PDFs that just contain the pages you need and then dump those to a watched folder.
s
Hi, I work with @Jason Vicari. In our case, our web app is only used internally by our company, and we print to local printers within the same building, so using <cfprint> makes sense. We converted from CF to Lucee recently, and so this is one of the features we lost when doing so. I understand that it's possible to write a custom library in Java and add it to Lucee, which might be the way we go. Neither of us are skilled in Java, but we can probably get it done. (If anyone has some tutorials/resources for this, that'd be awesome!) If we can't get that working, we are indeed exploring other options to print; we have a few ways that we can get around it, but obviously none are as ideal as being able to do it from within Lucee itself.
e
Here is how you do this, and yes, I would like 20 dollars in beer for the help. Install a cups printer, if you are not sure what CUPS is, figure it out. Its a linux / mac software service to run a printer. Install NCAT, its a command line utility for manipulating various network data. Finally, either by cfexecute or using sh script, run ncat -v -w 3 localhost 9100 < /path/to/print-file.pdf
s
Thanks 🙂 Probably should've mentioned that we're running this on a Windows box w/ IIS though lol. But that is indeed the general idea if we can't create our own library.
e
@Sean, Cygwin is your friend. Its an open source, binary port of the UNIX/LINUX binaries. You can find it here: https://www.cygwin.com/ Install CYGWIN and install at least NCAT; if everything is Windows, then you will install CUPS on the "Print server." Setup the "Printer" in cups; then run your print job, and you're good.