integrating cloud print was a mistake
As you might have gathered from previous blog posts, I work for a fashion company and have taken over the technical support of their online shop, fixing or implementing any vulnerabilities or technical improvements.
In the large warehouse of the online shop, iPods with a scanner case are used to collect and send the parcels, on which an app from the shipping provider runs. This app can of course also print shipping labels via a thermal printer.
The Problem
The only problem here is the printer service provided by iPhones or iPods, either printers can be connected via the app that natively support AirPrint, are connected via a Mac computer via USB and shared in the network or via Google Cloud Print.
However, thermal printers often do not have the option of being connected via AirPrint, let alone have a network card. Connecting via USB using a separate MAC computer also seems pointless as it then has to be permanently online... so the only option left is Google Cloud Print to connect the thermal printers.
Fortunately, Google has completely discontinued support for their cloud printing service as of 01.01.2021 (yes, that's sarcasm) and updates for the app to an alternative service are of course not available either, YEEEEHAAAAWW 😍! (yep, also sarcasm).
The Solution
Well, it can't really get any easier. Because Mac OS has a simple Cups service running in the background that releases the printers connected via USB on port 631 when sharing and CUPS is also available on Linux, I opted for a Raspberry. Surprisingly, this works very well.
I simply installed Debian (Raspbian) on the Raspberry Pi3, configured a static IP, installed a network cable, installed Cups and connected all printers via USB.
sudo apt-get install cups
First we allow administration via the network. Later, we can administer the CUPS server from any client on the network in a web browser.
sudo cupsctl --remote-admin
The next setting allows the locally set up printers to be shared on the network (printer sharing).
sudo cupsctl --share-printers
The following setting allows printing from any computer on the network.
sudo cupsctl --remote-any
Then we have to add a user to the user group "lpadmin". This can be the standard user "pi". You can also create a new user for this if you wish. However, this is not absolutely necessary, you can this step als root also, if so ignore this step.
sudo usermod -aG lpadmin pi
Afterwards, a restart of the CUPS server is necessary.
sudo systemctl restart cups
now we can access the CUPS web interface via IP and port 631.
With our Zebra thermal printers this was very easy, we just had to connect the printer via USB. Then in the CUPS web interface under Printer -> Add Printer, select the port with the Zebra printer and click on Next, just make sure that you click on "Share this printer on the network", the driver was already installed and only had to be selected.
Most printers have linux drivers anyway, just install them via the command line and they are automatically displayed in CUPS for selection, very cool.
Well we have now connected all the printers and added them to CUPS, now what? We have the option of setting up printers manually on the iPods. To do this, we open the app From Shipping Service Provider and add the link from CUPS under Printer Configuration, i.e. IP:631/printers/PRINTERNAME, so that they can be controlled.
Now the printers can be addressed normally via AirPrint (also works in the normal printer dialogue from iPhones or iPods, of course also on MAC OS).
Also a cool way to make your old USB printers fully AirPrint capable. 🤯
🥰 Additional problems and troubles 😍
We all love and appreciate them, problems that come up only after using a cool idea. Here is a small additional list of all the problems we had with this setup and also the corresponding solutions (hopefully).
180 degree thingy
We also had the problem with the original driver for the explicitly described model, but with our thermal printers the shipping labels were simply printed upside down. Unfortunately, there are no exact settings for AirPrint (at least on the iPod or iPhone), so we had to solve the problem on the CUPS page, but it works well, so it's not so bad.
Source reference: https://askubuntu.com/questions/954779/change-printer-orientation-in-terminal
We connect via terminal to our Raspberry and edit our Printer.conf.
sudo nano /etc/cups/printers.conf
We look for our printer in the list, the printers are divided into <DefaultPrinter> and end with </DefaultPrinter> who has basic HTML knowledge, this will seem logical to you.
With our printer, we simply add this one line and all print jobs to this printer are rotated 180 degrees.
Option orientation-requested 6
now just save and restart the cups service, problem solved.
2021 and still no linux drivers
You are only really fucked if you are using a printer for which no standard driver works and no Linux driver is provided on the official website. We had exactly this problem with a Chinese NoName thermal printer.
The only option left is to download 7-Zip onto a Windows computer and disassemble the driver files down to the smallest detail, a ppd file would be important here. This is used by CUPS as a driver and contains all the necessary information. Sometimes this can be traced in drivers. However, this is a tedious process that takes a lot of time.
Infos regarding this problem
1: https://www.suse.com/support/kb/doc/?id=000016775
2: https://forum.porteus.org/viewtopic.php?t=2079
please inform yourself in advance about linux capable printers as it seems that many manufacturers don't give a damn if they support linux, it's not impossible but much more difficult than getting the driver directly from the manufacturer ready to install.