Is it possible to print from PHP directly to a networked printer?
Looking at having someone fill out a form on a site, and instead of emailing that we’d like to sent it directly to the IP address of a networked printer.
Any thoughts?
Is it possible to print from PHP directly to a networked printer?
Looking at having someone fill out a form on a site, and instead of emailing that we’d like to sent it directly to the IP address of a networked printer.
Any thoughts?
Couldn’t you use exec() to fire up lprint?
(Or then again you could always use Cups, been waiting a long time to say that )
I expected much more from you…shakes head
Haha - sounds like an in-joke there…
I should have mentioned: it’s a shared hosting environment, so I don’t think I’ll have access to any linux command line stuff. Probably skuttles the plan?
Ah - just noticed the name. Thanks Cups! (facepalm)
Sorry Rocky, yes, it was a bit of an in-joke.
Lets try and sort out exactly what you want then. It sounded to me as if you were working on an intranet.
You want website visitors to fill in a form on your website, hosted on a shared webserver, and you want the bit of paper to come out of a printer in your office?
Is that about it?
What frequency do you want to print things off at? e.g. Do you want a download that prints them twice a day, or as soon as a new “order” is received?
Don’t you want an electronic backup of the data?
Yes - that’s about it. We have a fixed IP address and can port forward the data from the router in the office direct to a printer with it’s own internal IP address. I just need to figure out how to get it from the form to our router.
The scenario we’re investigating is actually for a food retailer - so people could order online and have the order print out immediately in their shop. (They have the internet on in their shop, and a printer, but no computer. Why? I dunno, good question. But that’s the setup.)
I’m thinking they should just buy a cheap computer and we can use a rule in outlook to print emails as they arrive…
Hold the bus.
They are in Seattle, order some food online via your server in NY, and the piece of paper emerges magically from a printer in the back room of “The Local Food Joint Seattle”.
Is that what you mean?
Yep - pretty much.
But the names and locations have been changed to protect the innocent.
In principle it sounds pretty straightforward.
1 public user creates an order, save the order in the central database.
2 private user (client side) polls the database every minute, maybe using Ajax, finds an order for Seattle, takes the order, flags something in the database.
3 a daemon on the server periodically checks for orders (5 minutes?) which have been created > 1 minute which have not been flagged - so discovering a potential problem and alerts some higher being.
4 Seattle computer client side application, in JS say, finds a condition has been met, an order received and in JS sends it to the printer.
That last bit I have never done, but it should be easy to test.
Go to the JS forum and ask how one can set up a timer to check a condition via Ajax and send some text to a printer.
Step 2 above could be changed from “pull” to “push” so that the central server broadcasts the information to Seattle, but I cannot see any great benefit.
No need to use Ajax of course, just set a 1 minute refresh in a html meta tag, just to get a proof of concept up and running.
Hmmm… not quite what I had in mind - but that could work. I like point 3 as well - good idea.
Easy enough to bring up a print dialogue boc in JS - automatically sending it to a specific printer could be a challenge though.
Thanks Cups - will do some more digging…
Could you set a web server up local to the printer, which could accept incoming orders (via some kind of API) and print them from there using standard shell commands?
Having the printer local to the web server is not really necessary - networked printers have an IP address - and as long as the shop it’s in has a static IP we can print to the IP address of the shop and port forward internally to the printer.
Just need to get the data from the website form to a print command somewhow - and we don’t have a dedicated server so we don’t have root access. It’s in a shared environment. Tricky one.
Easy enough to bring up a print dialogue boc in JS - automatically sending it to a specific printer could be a challenge though.
Don’t need a dialog box.
onload=print, meta refresh 1 minute later, if nothing to report, then default message.
I would have thought it would be up to the shop locally to have their printer set up correctly in the browsers’ settings somewhere.
Seems hacky though, I must admit.
This sounds as if it could be one of the things Python could do better, keep the whole browser thing out of it.