Create Print Job via PHP on Remote Printer (dynamic ip)

I am looking to fiddle around to find a solution for being able to automatically get a remote printer to print a file/string while the printer is not within the same network or server.

Use case for example would be an online order - let’s say you order a pizza, and the order will generate the printing job which triggers a printer with internet access to print that said order so the kitchen will know what kind of pizza has to be made.

While i have seen some attempts for internal printers, i can’t use that in this case, as a pizza-place would most likely have changing ip adresses every 24h so i am sure creating a job via ip/port combination is not the best solution - even though could use a dynamic ip cloaking…

I have seen that there’s a little wrapper for google cloud print, which is most likely the idea i would try to approach but i couldn’t seem to get those to work. Similar to that if the printer is manufactured by HP, i could have the option to use the e-print service to for example use mail() and send my order to the eprint-service but that would obviously require a hp printer…

I know kirby is not really related so I am not asking for a thoughout support, however getting some ideas for any other approach - or anyone who has attempted (successfully?) something similar to that, would be very beneficial…

How about a local RaspberryPi with webserver that polls the external webserver?

yeah. i have also read about using a RPI to get your printer into the web, but still i would have to get around the dynamic ip with raspberry pi…

let’s say the ip changes after 24h and the dynamic ip service hasn’t been updated just in time. so a printing job might not reach it’s destination or is there any way around it to always make sure the ip adress is instantly up to date…

That’s why i wrote: “polls the external webserver” so there is no need for a dynIPservice or opening/forwarding ports on the router (very bad idea… hackers will penetrate the port 24/7)

Maybe the local kitchen-pi does not need a webserver. It should be possible with some shellscript magic…or python.

Run something every 60 seconds like this:

/bin/bash -c "sleep 10 && while true; do <path_to_your_script.sh> ; sleep 50; done"

Or set up a CRON.

Print from shell with lpr: https://www.computerhope.com/unix/ulpr.htm

i have given the google cloudprint via api wrapper another go and got it working which is most likely exactly what/how i want. i am just wondering about the refresh_token there, if i need to save it once and it’ll work or if that token will expire…

This might help, it can get around the Dynamic IP problem. I’ve used it before to serve a webserver publicly from my house on consumer broadband with dynamic IP. https://dyn.com/dynamic-dns/

@jimbobrjames

dyndns such as no-ip, ddns and other services are no news to me unfortunately. the issue i see with those is that when a new ip is drawn from ISP it won’t be refreshed immediately. while this might only could cause issues once in a while (if unlucky)… so any attempt might resolve to the old ip once the refreshed one is not available yet.

not to mention for example no-ip.com wants to verify your account every 30 days if you are not paying them.

to be honest, if i were to sacrifice one of my RPI for such a use case, i would worry about security as @svnt said - while printing is nice, a RPI as a full fledged computer could turn quite bad if being hacked. being passively attached to a printer would mean noone would even notice if there has been unauthorized access as long as it’s printing fine…

i do not require it on a production site as i want to play around with this first to see if any can be applied if any use-case should arise…

in comparision with the google cloudprint, the wrapper seems to work setting up to use for offline (no account authorization - just once)

having just a few files, i could generate pdf’s directly sending it without ever worrying about ips because it’s working with google client api / account.

personal experience with cloudprint has been good, i wonder if i were to send about 10-20 print-jobs at once (or in a short timespan) to see what works.