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

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

Open
3 tasks done
SkySails opened this issue Jan 12, 2023 · 11 comments
Open
3 tasks done
Labels
22-x-y bug 🪲 component/printing has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/macOS

Comments

@SkySails
Copy link

SkySails commented Jan 12, 2023

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 #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.

@ckerr ckerr added platform/macOS component/printing 22-x-y has-repro-gist Issue can be reproduced with code at https://gist.github.com/ labels Jan 25, 2023
c3er added a commit to c3er/mdview that referenced this issue Feb 25, 2023
On macOS, it should be possible to print a PDF file without an
installed printer. But the Electron framework prevents this.

See electron/electron#36897
for more information.
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Apr 26, 2023
@SkySails
Copy link
Author

This issue is still present in v24.1.2 as well as v25.0.0-alpha.5.

@github-actions github-actions bot removed the stale label Apr 27, 2023
luxuereal pushed a commit to luxuereal/md_viewer_electron that referenced this issue Jun 16, 2023
On macOS, it should be possible to print a PDF file without an
installed printer. But the Electron framework prevents this.

See electron/electron#36897
for more information.
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Jul 26, 2023
@SkySails
Copy link
Author

SkySails commented Jul 27, 2023

This issue is still present in v26.0.0-beta.8.

Additionally, it looks like undefined is no longer acceptable, which contradicts the types. Pressing print (native) yields:

(node:17207) UnhandledPromiseRejectionWarning: Error: webContents.print(): Invalid print settings specified.
    at WebContents.print (node:electron/js2c/browser_init:2:84359)
    at /private/var/folders/4d/5942_yrx0d3_wdvtrr8l221r0000gn/T/electron-fiddle-16690-OJTXZeaRLftR/main.js:34:63
    at new Promise (<anonymous>)
    at /private/var/folders/4d/5942_yrx0d3_wdvtrr8l221r0000gn/T/electron-fiddle-16690-OJTXZeaRLftR/main.js:34:5
    at WebContents.<anonymous> (node:electron/js2c/browser_init:2:89068)
    at WebContents.emit (node:events:513:28)

Changing this out for an empty object restores the old behavior, with No printers available on the network being logged instead. The JS solution still works!

@github-actions github-actions bot removed the stale label Jul 28, 2023
@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@SkySails
Copy link
Author

This issue is still present in v27.0.2 as well as 28.0.0-alpha.6.

luxuereal pushed a commit to luxuereal/md_viewer_electron that referenced this issue Dec 12, 2023
On macOS, it should be possible to print a PDF file without an
installed printer. But the Electron framework prevents this.

See electron/electron#36897
for more information.
luxuereal added a commit to luxuereal/md_viewer_electron that referenced this issue Dec 12, 2023
On macOS, it should be possible to print a PDF file without an
installed printer. But the Electron framework prevents this.

See electron/electron#36897
for more information.
@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@pushkin-
Copy link

bump

@SkySails
Copy link
Author

This issue is still present in v28.2.0 as well as 29.0.0-beta.4.

@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@SkySails
Copy link
Author

SkySails commented May 1, 2024

This issue is still present in v30.0.1 and 31.0.0-alpha.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
22-x-y bug 🪲 component/printing has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/macOS
Projects
None yet
Development

No branches or pull requests

3 participants