HomeSoftware DevelopmentCUPS and Raspberry Pi AirPrinting

CUPS and Raspberry Pi AirPrinting

Whereas printing to paper perpetually appears to be “going the best way of the Dodo,” the necessity to print one thing on an precise piece of paper nonetheless has a manner of displaying up after we least count on (or need) to see it. Naturally, nobody who encounters this want on a cell system actually desires to stand up and print the identical doc from a conventional laptop. As anybody who steadily makes use of the AirPrint characteristic on an iPhone can attest, most consumer-grade printers’ assist for AirPrint is sketchy at finest. For many, all it takes is for the printer to enter an prolonged sleep and it’s not out there for AirPrint till it’s manually woken up by a human.

Leveraging Linux and the Raspberry Pi for AirPrint

For a lot of a long time Unix – and in a while Linux – has provided sturdy printer-sharing options. CUPS, shorthand for Widespread Unix Printing System, is the go-to server device for managing entry to printers that have to be shared with a number of customers on a community. The Raspberry Pi system provides a low-cost {hardware} resolution, each when it comes to buy value and operational value, that enables for customers to leverage Linux and CUPS for the needs of sharing a printer over a community.

A Raspberry Pi 4 with 4GB of RAM operating Raspberry Pi OS model 11 (Bullseye) was used for the needs of this embedded programming tutorial. The default pi person account was used to configure the service. The printer used for this demonstration was a Canon MG 3222. The Raspberry Pi system should be linked to the identical LAN that the iOS gadgets are linked to. This doesn’t imply that it should be linked wirelessly. Ideally the Raspberry Pi ought to have a wired Ethernet connection into the identical community that the Wi-fi Entry Level or Wi-fi Router serves.

The Raspberry Pi OS, previously generally known as Raspbian, usually consists of the CUPS daemon, generally known as cupsd put in and set to run on boot by default. If this isn’t the case, the daemon will be put in and enabled utilizing the apt bundle supervisor and systemctl service supervisor. If cupsd isn’t configured to run at boot, it should be manually enabled or printing is not going to work.

Learn: Utilizing a Raspberry Pi Gadget as an OpenVPN Server

How you can Configure CUPS

To make sure that cupsd is certainly operating, use the command:

[email protected]:~ $ systemctl standing cups

This could return a display just like the one under. Relying on the system setup, a sudo prefix could also be required:

Verify that CUPS is installed and running

Determine 1 – Confirm that CUPS is put in and operating

By default, the pi person account ought to be configured as a member of the lpadmin Linux group. This may be verified with the command:

[email protected]:~ $ cat /and many others/group | grep lpadmin

Confirm that the pi user is a member of the lpadmin group

Determine 2 – Verify that the pi person is a member of the lpadmin group

This exhibits that the pi person is a member of the lpadmin group. If this isn’t the case, or if an account aside from pi is getting used, then that group task must be made earlier than persevering with or else it is not going to be attainable to configure the print server.

How you can Set up the foomatic-db Package deal

The foomatic-db Linux bundle provides considerably to the checklist of printers that Linux is ready to assist, and it ought to be put in if not already current:

[email protected]:~ $ apt checklist –put in | grep foomatic-db

If no outcomes are returned, use the bundle supervisor to put in it:

[email protected]:~ $ sudo apt-get set up foomatic-db

How you can Entry CUPS

CUPS is web-managed, which means it may be accessed by opening a browser inside Raspberry Pi and searching to https://localhost:631 (an invalid certificates warning will seem and will be dismissed). The next display ought to seem:

CUPS Home Page via “fake” https

Determine 3 – CUPS Dwelling Web page through “faux” https

IMPORTANT NOTE: Whereas cupsd isn’t usually configured by default to permit entry to the net administration web page from outdoors of localhost, this isn’t assured. It must also be verified that the system can’t be browsed to externally.

Verifying Printer Configuration

As not each printer performs properly with Linux, it is going to be mandatory to verify that the printer is each linked to the Raspberry Pi system and configured within the Raspberry Pi OS. Fortuitously, CUPS makes it straightforward to do each. Ensure that the printer is linked on to the Raspberry Pi system through USB. Throughout the CUPS homepage, click on on the “Administration” tab and the next display ought to seem:

CUPS Administration Tab

Determine 4 – CUPS Administration Tab

Click on on the “Add Printer” button. A immediate for the credentials will seem. For this demonstration, the userid and password of the pi person account might be entered. Notice that solely members of the lpadmin group will be capable to efficiently authenticate at this immediate.

IMPORTANT NOTE: cupsd by default permits for each http and https entry. This may be managed within the configuration file, however within the meantime, be conscious to not enter passwords on an http web page. If this web page is to be accessed remotely, it’s strongly really useful to make use of a correct SSL certificates.

IMPORTANT NOTE: Trendy Linux installations ought to by no means be configured with a root password or permit for direct root login, but when the Raspberry Pi system is configured in such a manner, the foundation password ought to by no means below any circumstances be used right here.

Authentication Page - Credentials for lpadmin group member needed

Determine 5 – Authentication Web page – Credentials for lpadmin group member wanted

Upon efficiently logging in, any supported printer might be detected. On this case, the specified printer is the Canon MG3200 sequence, because the printer is a Canon MG3222 printer:

Initial Printer Selection

Determine 6 – Preliminary Printer Choice

Choose the printer and click on the “Proceed” button. An appropriate description and identify ought to be used for the printer, and the “Share This Printer” checkbox ought to be checked:

Printer Description Entry

Determine 7 – Printer Description Entry

Upon finishing this web page, click on the “Proceed” button:

Extended Printer Model Selection thanks to foomatic-db

Determine 8 – Prolonged Printer Mannequin Choice because of foomatic-db

The addition of the foomatic-db bundle enabled the Canon MG3222 printer to be routinely found by CUPS, and offered a urged driver for a similar. If the printer’s make and mannequin aren’t listed, it’s attainable, albeit far tougher, to utilize a PPD (PostScript Printer Definition) file if one will be discovered for that printer.

IMPORTANT NOTE: Whereas it’s attainable to repeat a PPD file from one other system, there is no such thing as a assure that it’ll work, as there could also be settings hard-coded throughout the PPD file for that different system.

Upon choosing the suitable printer make and mannequin, click on the “Add Printer” button. The following display will permit for the printer’s default choices to be set:

Printer Options - Updated with Desired Values

Determine 9 – Printer Choices – Up to date with Desired Values

Notice that for some printers, it is going to be essential to scroll the web page to see the entire choices together with the “Set Default Choices” button. Notice, additionally, that there could also be different choices below different tabs, together with “Banners” and “Insurance policies” tabs. These ought to be verified earlier than persevering with. Relying on the printer, not the entire tabs could also be current.

As soon as the specified default settings are in place, click on the “Set Default Choices” button. The finished setup display (pay attention to the “Not Shared” bit) ought to then seem after an automated refresh of a shorter affirmation display:

Completed Printer Setup

Determine 10 – Accomplished Printer Setup

From this display, click on on the “Administration” tab within the very high menu bar as soon as once more.

Enabling Sharing

Determine 11 – Enabling Sharing

Click on each the “Share printers linked to this technique” and the “Enable printing from the Web” choices.

IMPORTANT NOTE: With this setup, the one factor stopping anybody from anyplace on this planet from printing to this printer is a correctly configured community firewall.

Click on the “Change Settings” button right here.

CUPS Server Restarting

Determine 12 – Server Restarting

IMPORTANT NOTE: The refresh settings of this web page could also be too quick to attend for the cupsd server to restart, and an error message could seem right here. If that occurs, wait just a few seconds and refresh the web page.

The Administration web page will now seem as above, with the sharing settings checked.

Learn: Utilizing the Web of Issues (IoT) with .NET

Elective Step: Configure Default Printer

If any printing is to be completed from the Raspberry Pi system itself, then this printer ought to be configured because the default for this system. This isn’t wanted for any AirPrint or different distant shopper although.

iOS Setup with CUPS

The next Apple gadgets have been used for this demonstration:

  • iPhone SE Second Technology operating iOS 15.1
  • iPad sixth Technology operating iOS 15.1

Each of those gadgets are linked to a WiFi community, which connects to a wired community on which the Raspberry Pi system sits. All gadgets are on the identical TCP/IP community phase.

The simplest technique to arrange a printer in iOS is to load up content material that one needs to print, after which use the “Print” dialog from throughout the software. For this demonstration, contemplate the picture under created within the “Notes” app on the iPhone:

iOS and CUPs tutorial

Determine 13 – A poorly drawn “Howdy World” picture, appropriate for framing.

Every app has its personal manner of printing, however for the “Notes” app, it may be completed by urgent the “Carried out’ button upon completion of the drawing, urgent the button that replaces it, and sliding the submenu up from the underside of the display:

CUPS and iOS Tutorial

CUPS iOS tutorials

Figures 14 and 15 – Printing from the “Notes” app

Whereas every app has its personal manner of printing, the printing course of for any given app, as soon as it’s accessed, is normally the identical. On this explicit iPhone, there is no such thing as a current printer configured, so there’s “No Printer Chosen” initially:

CUPS print dialogue

Determine 16 – The preliminary Print dialog with no printer configured

Tapping the “No Printer Chosen” button allows the iPhone to search for any AirPrint printers which are out there, and, positive sufficient, the one operating on the Raspberry Pi system will present up:

CUPS and AirPrint tutorial

Determine 17 – Discovering the brand new AirPrint Printer

Tapping on the “Canon MG3200 sequence” button will reveal the “Print” button, together with any one-time customizations that could be desired for the actual print job:

CUPS AirPrint tutorial

Determine 18 – The precise “Print” button

Tapping the “Print” button yields the completed product:

Guide to CUPS and AirPrinting

Determine 19 – The Printed Output

Going Additional: Different Units on CUPS

This setup, after all, isn’t restricted to only iOS gadgets. It will possibly work with any network-enabled system that may talk with CUPS. These embody Home windows computer systems, Mac OSX computer systems, and Android gadgets.

Learn: Working with Embedded Databases in Java

Conclusion to Raspberry Pi and Cups Airprinting

The Raspberry Pi can present a strong native print server that may meet the wants of the occasional and even frequent print person. It takes the frustration out of poor high quality AirPrint implementations and it could actually even create AirPrint entry with printers that don’t assist AirPrint, offered that they will work with CUPS. The opposite main benefit of utilizing this system is that the prices of leaving it on 24/7 whereas linked to the community are negligible.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments