electron: [Bug]: `webContents.print` fails on macOS with "No printers available on the network"

Preflight Checklist

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

Most upvoted comments

not sure if this is still an issue or not, but will give this a bump. Assumping it wasn’t randomly fixed