Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My iOS device is unable to print on double sides #102

Open
master-ang opened this issue Jan 7, 2025 · 21 comments
Open

My iOS device is unable to print on double sides #102

master-ang opened this issue Jan 7, 2025 · 21 comments
Labels
help wanted Extra attention is needed

Comments

@master-ang
Copy link

My printer supports automatic duplex printing, but I cannot achieve duplex printing with my iPhone 13 and iPhone X. In the iOS print settings, I can select "Double Sides Printing," but when I press the print button, nothing happens. However, if I cancel duplex printing, it prints successfully. Additionally, my Android phone, Windows computer, and Mac can all print on both sides successfully, only the iOS devices cannot. How can I resolve this issue?

@master-ang
Copy link
Author

My iPhone 13 does not have a duplex printing option, while my iPhone X does have the option but is unable to print.

@master-ang
Copy link
Author

@DrPsychick
Copy link
Collaborator

That link is interesting, because the answer links to a tutorial that basically shows how to install cups - exactly what this container does: https://discussions.apple.com/thread/255283321?answerId=259838859022&sortBy=rank#259838859022

So my best guess is to set duplex by default in the printer when setting it up with cups. Or have two printers configure (with same destination, if that works), one with duplex and one without? Does that help you?

@master-ang
Copy link
Author

I think this issue is likely caused by the iOS 17 update. I've been using it for a long time without any problems before. My printer model is quite old; it's the HP LaserJet 1320 series. I've continued to use it because its automatic duplex printing feature works very well. It seems that the iOS 17 update has upgraded the version of AirPrint, which is incompatible with the old driver of the 1320 model. I've tried all the 1320 drivers in your software and set the default to duplex printing, but none of these solutions worked. After upgrading my iPhone 13 to iOS 17, the duplex printing option simply doesn't show up. However, it's quite strange that my iPhone X, which only supports up to iOS 16, can display the duplex printing option but still can't print. Do you know where I can find a newer printer driver? I'd like to try manually updating the printer driver.

@DrPsychick
Copy link
Collaborator

I no longer use my own creation, because I have a new printer that supports AirPrint directly. This one (Brother DCP-L3550CDW) does show duplex printing on an iPhone 12 with iOS 18.

I fear it might be indeed the AirPrint support/version in this container. The script was taken from a dead repo, so we would need help from the community to understand and update it: https://github.com/tjfontaine/airprint-generate

@DrPsychick DrPsychick added the help wanted Extra attention is needed label Jan 8, 2025
@master-ang
Copy link
Author

Thank you for your analysis and response. I believe you are correct. It is likely not due to a specific printer driver, but rather the version of AirPrint supported by the container, which makes it difficult for me to resolve. Do you have any solutions? Can you try to take action?

@DrPsychick
Copy link
Collaborator

DrPsychick commented Jan 11, 2025

Since I'm unable to test it, can you try an build an image with some adjustments to https://github.com/SickHub/docker-cups-airprint/blob/master/airprint/airprint-generate.py?

Try adding <txt-record>Duplex=T</txt-record> around line 58, I would guess that may hardcode Duplex to True. Alternatively edit the generated AirPrint file in your running container and kill -HUP the cups process, I guess that should work by reloading the config.

If that works, we can figure out how to make it configurable.

@master-ang
Copy link
Author

I really want to do this, but my ability is limited. I can hardly understand these codes, and I don't have the prerequisite knowledge to know how to build image. I only have a QNAP NAS, from which I can pull images from the hub for installation and testing. Thank you for your exploration. I look forward to you or other experts like you creating an image, and I can help with the testing. I believe this can help all users who are using iOS 16 and later versions.

@DrPsychick
Copy link
Collaborator

Would you like to do it together? Because it will be difficult if not impossible for me to test.
If so, send me an email (see my profile) and I'll send you an invite to my slack where we can meet to chat and screenshare to resolve the issue. What do you think?

@master-ang
Copy link
Author

OK,i'll try my best.

@DrPsychick
Copy link
Collaborator

I had an idea how you can test it easily. I built a docker image with <txt-record>Duplex=T</txt-record> hardcoded, please give it a try and let me know if that enables duplex print for you. https://hub.docker.com/layers/drpsychick/airprint-bridge/duplex/images/sha256-a6d47ad361d58b60b2513178a4fc40f95f17cf69799a68624667e268a18bf760

If it does, I can open an issue with more detailed explanation and could start working on it when I find the time (or someone else).

@master-ang
Copy link
Author

master-ang commented Jan 17, 2025

It still doesn't work. I can see the duplex printing option on my iPhone X, but after clicking print, there's no response both the iPhone X and the printer, and docker-->CUPS-->“Jobs” doesn't receive any tasks.

If I don't select the duplex printing option, CUPS-->"Jobs" will receive task
and shows:
“processing since
Fri Jan 17 20:48:01 2025
"cfFilterChain: universal (PID 2131) exited with no errors."

The data light on the printer will flash, and the iPhone X will display a print page showing the "printing..." status, After the transfer is completed, the printing is successful.

I searched online and it appears that after the iOS upgrade, a newer version of the printer driver is needed. I believe the problem is likely not with CUPS, but rather the printer driver hasn't been updated for quite some time and is no longer compatible.

Unless CUPS can "translate" the printing requirements of the new iOS version into a format that the old printer driver can "accept".

@DrPsychick
Copy link
Collaborator

DrPsychick commented Jan 17, 2025

I'm sorry to hear that :(
That means we have to go deeper and need to understand the change in the protocol or at least better understand how that script makes printers available with options via AirPrint.

At the community out there: we would really appreciate your help to understand and improve the airprint-generate script.

There seem to be a lot of forks with lots of improvements around, so maybe we'll get lucky and someone already has a patch fot this issue: https://github.com/tjfontaine/airprint-generate/forks?include=active&page=1&period=5y&sort_by=stargazer_counts

@DrPsychick
Copy link
Collaborator

DrPsychick commented Jan 18, 2025

Yes, these look promising, give me some time to figure out what to change and build a new image for you to test 🤞

Edit: the mime files are already part of this image, so that's already covered.

@DrPsychick
Copy link
Collaborator

DrPsychick commented Jan 18, 2025

Do you have a Linux host with graphical interface and can install and run avahi-discover and post the results of the printer here? (see step 4 of the guide you posted: https://www.finnie.org/2010/11/13/airprint-and-linux/)

You can also instead post the XML file generated that is in your cups container in /etc/avahi/services/, so we can see the differences

Mine look like this, maybe that gets us a step closer to a solution

Service Type: _ipp._tcp
Service Name: Brother DCP-L3550CDW series
Domain Name: local
Interface: eno2 IPv4
Address: BRNBxxxxx.local/192.168.1.84:631
TXT mopria-certified = 1.3
TXT print_wfds = T
TXT UUID = e3248000-xxxx-yyyy-zzzz-aaaaaaaaaa
TXT PaperMax = legal-A4
TXT kind = document,envelope,label,postcard
TXT URF = SRGB24,W8,CP1,IS4-1,MT1-3-4-5-8-11,OB10,PQ4,RS600,V1.4,DM1
TXT TBCP = F
TXT Transparent = T
TXT Binary = T
TXT PaperCustom = T
TXT Scan = T
TXT Fax = F
TXT Duplex = T
TXT Copies = T
TXT Color = T
TXT usb_CMD = PJL,PCL,PCLXL,URF
TXT usb_MDL = DCP-L3550CDW series
TXT usb_MFG = Brother
TXT priority = 25
TXT adminurl = http://BRNBxxxxx.local./net/net/airprint.html
TXT product = (Brother DCP-L3550CDW series)
TXT ty = Brother DCP-L3550CDW series
TXT note =
TXT rp = ipp/print
TXT pdl = application/octet-stream,image/urf,image/jpeg,image/pwg-raster
TXT qtotal = 1
TXT txtvers = 1

ref: documentation of the XML avahi.service format (man 5 avahi.service): https://man.developpez.com/man5/avahi.service/

@master-ang
Copy link
Author

master-ang commented Jan 24, 2025

OK I found this:

“/etc/avahi/services/AirPrint-HP_LaserJet_1320_series.service"

<?xml_ version="1.0" ?><!DOCTYPE service-group SYSTEM 'avahi-service.dtd'><service-group><name replace-wildcards="yes">AirPrint HP_LaserJet_1320_series @ %h</name><service><type>_ipp._tcp</type><subtype>_universal._sub._ipp._tcp</subtype><port>631</port><txt-record>txtvers=1</txt-record><txt-record>qtotal=1</txt-record><txt-record>Transparent=T</txt-record><txt-record>URF=none</txt-record> <txt-record>Duplex=T</txt-record><txt-record>rp=printers/HP_LaserJet_1320_series</txt-record><txt-record>note=HP LaserJet 1320 series</txt-record><txt-record>PaperMax=legal-A4</txt-record><txt-record>product=(GPL Ghostscript)</txt-record><txt-record>printer-state=3</txt-record><txt-record>printer-type=0x829014</txt-record><txt-record>pdl=application/octet-stream,application/pdf,application/postscript,application/vnd.cups-raster,image/jpeg,image/png,image/tiff,image/urf,text/html,text/plain,application/pclm,application/vnd.adobe-reader-postscript,application/vnd.cups-pdf</txt-record></service></service-group>

@DrPsychick
Copy link
Collaborator

DrPsychick commented Jan 24, 2025

great, thanks. We'll see if we get any closer. Just found the BonjourPrinting.pdf with details on what the records mean: http://devimages.apple.com/opensource/BonjourPrinting.pdf

And yes, Duplex=T IS the right flag for duplex. I wonder why it has no effect for you.

I wonder if the URF= is worth exploring: https://wiki.debian.org/CUPSAirPrint
"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."
DM is DUPLEX SUPPORT

This links to a possibly newer Bonjour spec: https://developer.apple.com/bonjour/printing-specification/bonjourprinting-1.2.1.pdf (also not mentioning URF from what I saw)

=> I built and pushed a new image airprint-bridge:duplex which includes URF=DM1 - let me know if you can now print duplex again.

@master-ang
Copy link
Author

master-ang commented Jan 25, 2025

I don't know what went wrong, but this time I can't find the local printer. I've tried several versions of Docker, but none of them worked.I'll give it another try tomorrow.

@master-ang
Copy link
Author

master-ang commented Jan 26, 2025

I have some good news to share: the issue has been resolved!
The solution was quite unexpected.

Do you remember when I mentioned that I couldn't add my USB printer? I looked up some information online and found out that it was because I hadn't mapped the /dev/usb folder in the system.
Previously, I only mapped /dev/bus/usb and it worked, as I mentioned in my previous feedback Usb printers power off and avahi-deamon · Issue #35 · SickHub/docker-cups-airprint.

But suddenly, mapping only /dev/bus couldn't find the printer anymore (it used to work perfectly before).
When I created the Docker again, I mapped both /dev/usb and /dev/bus, and not only could I find the printer, but iPhone13PM could also print duplex normally!!

Furthermore, I conducted a series of tests, and the results are as follows:

version                iPhone13PM(iOS17.6.1)    iPhoneX(iOS15.4.1)    iPhone6P(iOS12.5.7)
latest-20250124          can duplex                  can't duplex           can't duplex
duplex                   can duplex                  can duplex             can duplex

I think your duplex version is still very effective!!!!!

Additionally, when I check the jobs now, the status of each successful entry is "Failed to connect to system bus".

HP_LaserJet_1320_series-1 | Unknown | Withheld | 644k | 2 | completed atSun Jan 26 21:38:15 2025 "Failed to connect to system bus"


HP_LaserJet_1320_series-2 | Unknown | Withheld | 226k | 2 | completed atSun Jan 26 21:38:45 2025 "Failed to connect to system bus"

The following content is displayed in the log.How to remove these warnings?

E [26/Jan/2025:21:38:01 +0800] [Job 1] Failed to connect to system bus
E [26/Jan/2025:21:38:24 +0800] [Client 119] Unable to encrypt connection: A TLS fatal alert has been received.
E [26/Jan/2025:21:38:31 +0800] [Job 2] Failed to connect to system bus
E [26/Jan/2025:21:52:35 +0800] [Client 295] Unable to encrypt connection: A TLS fatal alert has been received.
E [26/Jan/2025:21:52:35 +0800] [Client 297] Unable to encrypt connection: A TLS fatal alert has been received.

@DrPsychick
Copy link
Collaborator

Awesome! Luckily we did not go deep into debugging and just tested simple changes :) And besides, this thread may help others to resolve their issues.

As for /dev/bus and /dev/bus/usb - I think it should be enough to map the /dev/bus/usb as you're using your printer on USB. I'm not sure if /var/run/dbus is even needed, you can try leaving it out, then the errors/warnings might go away.

Concerning older iOS versions, I'm not sure if its worth investing the time to make this project compatible with them as they are end-of-life if I'm not mistaken.
With this issue and the details, I believe anyone can get it to work by hardcoding <txt-record>Duplex=T</txt-record> and <txt-record>URF=DM1</txt-record> in the airprint-generate.py file and building their own image.

Alternatively, if anyone wants to invest the time to make this configurable in that airprint-generate.py script, I will surely take time to review and merge it, if it works.

I'm glad it works now for you, @master-ang , and also thank you for sharing your findings. I hope this will help others in the community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants