tjfontaine / airprint-generate

Automatically generate AirPrint Avahi service files for CUPS printers
http://www.atxconsulting.com/blog/tjfontaine/2010/11/21/automatically-generate-airprint-avahi-service-files-cups-printers
405 stars 119 forks source link

Generate attributes for colour and paper size #34

Open callumgare opened 2 years ago

callumgare commented 2 years ago

Currently the avahi service file generated doesn't include whether the printer can print colour or not which causes iOS to assume the printer can only print black and white. It also doesn't include the default paper size which causes iOS to default to US letter size. This PR will cause it to add the colour flag if the printer supports colour and set the paper size to A4 if that's the default paper size of the printer.

callumgare commented 1 year ago

@Ljzd-PRO Thanks for approving this. Were you expecting me to merge it? Unfortunately I do not have write permissions to this repo so I can't merge.

Arnie97 commented 1 year ago

I would suggest using attrs.get(...) instead.

Traceback (most recent call last):
  File "/opt/./airprint-generate.py", line 289, in <module>
    apg.generate()
  File "/opt/./airprint-generate.py", line 184, in generate
    if attrs['color-supported']:
KeyError: 'color-supported'
Traceback (most recent call last):
  File "/opt/./airprint-generate.py", line 289, in <module>
    apg.generate()
  File "/opt/./airprint-generate.py", line 189, in generate
    if attrs['media-default'] == 'iso_a4_210x297mm':
KeyError: 'media-default'
callumgare commented 1 year ago

To be honest, it’s been so long since i wrote this and I no longer have a printer set up using this, so it would be difficult for me to make those changes and test it. Happy for anyone else to make those changes if desired.

sobjerke commented 7 months ago

Tested ok from iPad with cups-pdf virtual printer on Rocky Linux 9.3. Before applying the patch, iPad would only print in monochrome resulting in a monochrome PDF. After the patch was applied, color is available.