electron: [Bug]: `webContents.print` fails on macOS with "No printers available on the network"
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
22.0.1
What operating system are you using?
macOS
Operating System Version
macOS Ventura 13.0.1
What arch are you using?
arm64 (including Apple Silicon)
Last Known Working Electron version
No response
Expected Behavior
Calling the below:
window.webContents.print(undefined)
Should open a print dialog, regardless of whether or not any printers are configured.
Actual Behavior
When no printers are currently configured, calling the below:
window.webContents.print(undefined, console.log)
Yields
false No printers available on the network
While calling
window.webContents.executeJavaScript("window.print();")
Yields the expected dialog:
While I can use the second approach, it feels like a workaround rather than a solution.
The first approach works fine on Windows 10, perhaps because there are a few default printers such as “Microsoft Print to PDF”?
Testcase Gist URL
https://gist.github.com/8570c187ab7c976b70fd84835db5f27c
Additional Information
Could be slightly related to https://github.com/electron/electron/issues/24664. The error is not the same, but the result is. According to comments on that issue, this is “expected behavior” - but it is also noted that it is not per spec, as other applications behave differently.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 2
- Comments: 21 (2 by maintainers)
Commits related to this issue
- Add workaround for printing On macOS, it should be possible to print a PDF file without an installed printer. But the Electron framework prevents this. See https://github.com/electron/electron/issue... — committed to c3er/mdview by c3er 4 years ago
- Add workaround for printing On macOS, it should be possible to print a PDF file without an installed printer. But the Electron framework prevents this. See https://github.com/electron/electron/issue... — committed to luxuereal/md_viewer_electron by luxuereal 4 years ago
- Add workaround for printing On macOS, it should be possible to print a PDF file without an installed printer. But the Electron framework prevents this. See https://github.com/electron/electron/issue... — committed to luxuereal/md_viewer_electron by luxuereal 4 years ago
- Add workaround for printing On macOS, it should be possible to print a PDF file without an installed printer. But the Electron framework prevents this. See https://github.com/electron/electron/issue... — committed to luxuereal/md_viewer_electron by luxuereal 4 years ago
not sure if this is still an issue or not, but will give this a bump. Assumping it wasn’t randomly fixed