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

webContent.print fail because "No valid printers available" #24664

Closed
3 tasks done
abnerlee opened this issue Jul 21, 2020 · 7 comments
Closed
3 tasks done

webContent.print fail because "No valid printers available" #24664

abnerlee opened this issue Jul 21, 2020 · 7 comments

Comments

@abnerlee
Copy link

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 an issue that matches the one I want to file, without success.

Issue Details

When I run webContents.print (https://www.electronjs.org/docs/api/web-contents#contentsprintoptions-callback):

webContents.print({silent:false}, (success, failureReason) => {
  // success will be false
 // failureReason will be "No valid printers available"
});

Instead of popping up a print setting dialog, the callback will return with failureReason of "No valid printers available".

In windows, it works fine.

  • Electron Version:
    • 8.x / 9.1.1
  • Operating System:
    • macOS 10.15.5
  • Last Known Working Electron version:
    • 6.x

Expected Behavior

popping up a print setting dialog

Actual Behavior

the callback will return with failureReason of "No valid printers available".

Additional Information

Windows version works fine

@codebytere
Copy link
Member

This is expected behavior. Our print logic will not proceed unless your machine has a valid printer on the network configured.

@abnerlee
Copy link
Author

@codebytere This should be the spec when silent is true, when silent is false, it should "ask user for print settings"

I can show the dialog on xcode and other apps even when there's no printers, because even when there's no printers, PDF, send in mail, etc should be supported.

截屏2020-07-22 21 27 26

@abnerlee
Copy link
Author

abnerlee commented Aug 4, 2020

sorry @codebytere, would you confirm why electron uses a spec that differs from other apps?

And it should work well on electron 6.x

@andsmedeiros
Copy link

I can confirm this on Ubuntu 20.04, Linux 5.4.0-45-generic and Electron 10.1.1.
From the devtools, calling window.print() opens the print dialog as expected.
Calling electron.remote.getCurrentWebContents().print() fails silently. Logging the callback arguments yields "no valid printers available". There ARE available printers.
I will try it on Windows later.

@mdg1019
Copy link

mdg1019 commented Nov 5, 2020

I'm using Ubuntu 20.04 and Electron 10.1.2 and am experiencing the same issue.

@abnerlee
Copy link
Author

abnerlee commented Nov 21, 2020

-> #25498

in my test, #25607 did not fix this.

@caffeinatedbits
Copy link

I ran into this same issue using a BrowserWindow which contains multiple BrowserViews on macOS. As a temporary fix, I used ipcMain to send a message via BrowserView.webContents.send("print") and, within the BrowserView, ipcRenderer to listen for that via ipcRenderer.on("print"). Then, within that listener, I call window.print(). Problem solved for now, though BrowserView.webContents.print() should do the same thing, which instead still returns the error mentioned ("no valid printers available") as of electron@12.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants