Differences between revisions 16 and 20 (spanning 4 versions)
Revision 16 as of 2021-02-19 14:53:51
Size: 10622
Editor: Brian Potkin
Comment: Added to the Upstream CUPS and AirPrint section. A link in Caveat.
Revision 20 as of 2022-04-12 16:46:18
Size: 11037
Editor: Brian Potkin
Comment: Noted AirPrint is now supported by CUPS.
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
[[#debiancups|Enabling]] an [[WikiPedia:IOS|iOS device]] to print via [[WikiPedia:AirPrint|AirPrint]] on a Debian 9 (stretch) and Debian 10 (buster) [[SystemPrinting|CUPS]] printing system. ## This page is release-specific because the support for image/urf
## was added to cups-filters for the Debian 9 (stretch) release and
## it has not yet been removed from cups-filters.

[[#debiancups|Enabling]] an [[WikiPedia:IOS|iOS device]] to print via [[WikiPedia:AirPrint|AirPrint]] on a Debian 9 (stretch) or later [[SystemPrinting|CUPS]] printing system.
Line 154: Line 158:
!OpenPrinting CUPS' stance on supporting !AirpPrint is expressed in [[https://github.com/OpenPrinting/cups/pull/27|pull request #27]]. !OpenPrinting CUPS' stance on supporting !AirpPrint is expressed in [[https://github.com/OpenPrinting/cups/pull/27|pull request #27]]. After a period of development, the changelog for CUPS v2.4b1 (27th October 2021) was able to announce:

{{{#!wiki note
- Added support for !AirPrint and Mopria clients ([[https://github.com/OpenPrinting/cups/pull/105|Issue #105]])
}}}

Translation(s): none


Enabling an iOS device to print via AirPrint on a Debian 9 (stretch) or later CUPS printing system.

What is AirPrint and How Does it Work?

AirPrint was devised by Apple Inc to enable an iPhone, an iPad, an iPod Touch or a Mac, referred to as iOS clients (or just clients) to print without having to install drivers on the client device. More and more new printers come with firmware to support AirPrint. In fact, it would be unusual nowadays for a network-aware printer not to provide AirPrint support.

There are two technologies central to the AirPrint facility on a printer:

The broadcast mDNS packets contain information about the capabilities of the printer, its identity and its location on the network. They also utilise some extensions (not necessarily fully explained in existing literature) to the existing Bonjour specification to allow iOS clients to search specifically for AirPrint-capable printers and display them in a print dialogue.

IPP (version 2.0) is needed for print management. The client uses IPP to send the print job with information about what printer language it is in, whether it is to be duplexed, the number of copies, the resolution to be used for printing, the media output location on the printer etc.

Browsing an AirPrint Bonjour Broadcast

On Debian, avahi-daemon is essential to detect the Bonjour broadcasts from a printer. Utilities which interact with avahi-daemon are in the avahi-utils package and mDNS and DNS-SD services can be browsed wth avahi-browse.

The command

avahi-browse -art > discovered

gets all broadcast print queues (and more) on a subnet and records them in the file discovered. For a view of printers only there is

avahi-browse -rt _ipp._tcp > discovered

This is the reformatted output for an AirPrint enabled HP ENVY 4520:

=   eth0 IPv4 HP ENVY 4500 series   Internet Printer  local
   hostname = [envy4500.local]
   address = [192.168.7.235]
   port = [631]
   txt = ["Scan=T"
          "Duplex=T"
          "Color=T"
          "UUID=1c852a4d-b800-1f08-abcd-308d99fafac2"
          "Fax=F"
          "note="
          "adminurl=http://envy4500.local./#hId-pgAirPrint"
          "mac=30:8d:99:fa:fa:c2"
          "priority=20"
          "usb_MDL=ENVY 4500 series"
          "usb_MFG=HP"
          "product=(HP ENVY 4500 series)"
          "ty=ENVY 4500 series"
          "URF=CP1,MT1-2-8-9-10-11,OB9,OFU0,PQ3-4-5,RS300-600,SRGB24,W8-16,DEVW8-16,DEVRGB24-48,ADOBERGB24-48,DM3,IS1,V1.3"
          "kind=document,envelope,photo"
          "PaperMax=<legal-A4"
          "rp=ipp/print"
          "pdl=application/vnd.hp-PCL,image/jpeg,application/PCLm,image/urf"
          "qtotal=1"
          "txtvers=1"]

Note the line beginning URF=. This enables the client to discover the printer and also tells the client what the printer is capable of doing.

The Bonjour Printing Specification Version 1.2.1 is a good source for understanding most of the TXT Record (txt =), apart from the URF entry. For that you might find Patent US 20110194124 A1 useful.

The URF key is one of extensions to the Bonjour Printing Specification mentioned previously. Its documentation is sparse. It can be deduced from US 20110194124 that

  • CP is MAX COPIES
  • MT is MEDIA TYPES
  • OB is OUTPUT BINS
  • OF is FINISHINGS
  • PQ is PRINT QUALITIES
  • RS is RESOLUTIONS
  • SRGB is COLOR SPACES
  • W is BIT DEPTHS
  • DM is DUPLEX SUPPORT
  • IS is INPUT SLOTS.

The pdl (Page Description Language) key is important. It lists the only MIME types the printer will accept for printing. With or without AirPrint enabled the Envy 4520 will not process a PostScript or PDF document sent to it. AirPrint adds nothing to this printer's capability to deal with document types its firmware is not built to cope with.

Note the last entry in the pdl key, image/urf, known as Apple Raster. It is a fallback MIME type for the client to send to guarantee printing takes place and it is obligatory for it to be accepted by a printer claiming AirPrint compatibility. image/urf is raster data; there are no officially published details about it but it has been reverse engineered.

Actually an iOS client supports sending three MIME types: application/pdf, image/jpeg and image/urf. It also knows what data types the Envy 4520 will accept. Therefore, a JPEG photo would be sent to the printer as image/jpeg and anything else would go as the fallback image/urf.

If the pdl key for the printer had been

  application/vnd.hp-PCL,application/pdf,image/urf

a PDF would be sent unaltered and everything else as image/urf. The fallback image/urf isn't needed for the PDF because application/pdf is the first supported MIME type found in the key and the client knows the printer to be capable of printing it.

Summary-1

Printing from an iPhone, an iPad, an iPod Touch or a Mac to an AirPrint- enabled printer should just work.

Upstream CUPS and AirPrint

It didn't take long after the introduction of AirPrint for people with iOS clients to want to print to their non-AirPrint printers by having CUPS advertise queues which a client would be happy to deal with. However, upstream's position on including AirPrint support in mainline CUPS is expressed in Issue #4341 and Issue #4357:

  Sorry, but we do not support AirPrint for shared printers served by CUPS.

  CUPS does not support iOS. The two are not compatible,

This view is expanded on with

  CUPS does not support everything that AirPrint needs, and many drivers
  do strange things (particularly on OS X) when you don't go through the
  local print dialog.

  Generally speaking you can get away with it for common office printers
  using US Letter and A4 paper, but that's about it.

And elsewhere:

  Printing of emails and web pages to Letter/A4 media generally works, but
  as soon as you go beyond that things fall apart pretty quickly.  Here is
  a short list of what does not work when using CUPS as an AirPrint
  server:

  - Ready media (that's how you get to pick media sizes on iOS)
  - Many printer status keywords ("out of paper", etc.)
  - Proper media selection and scaling when printing photos
  - Proper media selection, rotation, and scaling when printing PDFs
  - Duplex printing with some drivers
  - Color/grayscale mode
  - Copies (yes, really!)

  Some of these deficiencies would require major changes to CUPS and its
  driver architecture to fix, others require driver and (in some cases)
  printer firmware updates to correct.

OpenPrinting CUPS' stance on supporting AirpPrint is expressed in pull request #27. After a period of development, the changelog for CUPS v2.4b1 (27th October 2021) was able to announce:

- Added support for AirPrint and Mopria clients (Issue #105)

Debian CUPS and AirPrint

There are many users who wish to print from an iOS client to an incompatible printer. With the idea of emulating an AirPrint printer the necessary conditions for success are:

  • The non-AirPrint printer must be used with a print queue which is advertised using Bonjour broadcasting.

  • Communication between print queue and iOS client must be via IPP.

The first condition is met by setting up a print queue for the printer in the usual way. Bonjour broadcasting is automatically done when avahi-daemon is installed. Fulfilling the second condition requires avahi-daemon to broadcast a DNS-SD service type of _ipp._tcp or _ipps._tcp.

In principle there is no great problem in meeting the advertising and communication conditions. The problem arises in deciding what to put in a TXT Record to ensure a client recognises the broadcasts as coming from an AirPrint print queue and successfully prints to it.

In a process that to some extent involved trial and error, the Debian printing system has been patched and enhanced as follows:

  • Generate a TXT Record for a print queue with a URF key containing DM3.
  • Add image/urf to a pdl key.
  • Produce a Bonjour record automatically without the need of a .service file in /etc/avahi/services.
  • Have CUPS recognise and convert a file of MIME type image/urf to a PDF.
  • Introduce a filter into cups-filters to convert image/urf to application/PDF. The filter used on strech is urftopdf and on buster it is rastertopdf

After converting the Apple Raster to a PDF the filtering system can proceed with completing the remaining processes.

Summary-2

Printing from an iPhone, an iPad, an iPod Touch or a Mac to any correctly set up Debian print queue should just work.

Caveat

The way iOS clients handle AirPrint printing is determined by Apple and is likely to evolve over time. Future changes to iOS might impact on the ability of avahi-daemon and CUPS to service printing requests from a client; it has happened in the past.

Acknowledgements

Till Kamppeter <till.kamppeter@gmail.com> for implementing AirPrint support in Debian and Ubuntu and Didier 'OdyX' Raboud <odyx@debian.org> for supporting and overseeing its inclusion into Debian.

See Also


CategoryPrinter