You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I agree to follow the Code of Conduct that this project adheres to.
I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Electron Version
12.0.1
What operating system are you using?
macOS
Operating System Version
macOS Mojave 10.14.6
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
Calling webContents.print() should show the system print dialog.
Actual Behavior
Calling webContents.print() returns an error (via its callback, argument 2, failureReason) "no valid printers available" because I have no printers installed.
Testcase Gist URL
No response
I have a BrowserWindow which contains "print" button, and multiple BrowserViews. I tried calling view.webContents.print() (where view == the currently active BrowserView) when the print button is clicked, however, because I have no printers installed, the callback is immediately called with success == false and failureReason == "no valid printers available".
I am aware of the following issues which have been closed but not fixed:
In the main script, I am listening for that message using ipcMain, and then redirecting it to the appropriate BrowserView using view.webContents.send() like so:
const { ipcMain } = require('electron');
let currentBrowserView; // stores reference to the currently active BrowserView
ipcMain.on("print", (event) => {
currentBrowserView.webContents.send("print");
});
Finally, in the preload script for the BrowserView, I am listening for that message using ipcRenderer, and then calling window.print() like so:
This gets me the system print dialog which, despite not having any installed printers, offers me additional macOS features such as: Open in Preview, Save as PDF, Save as PostScript, Send in Mail, Add to Apple Books, Send via Messages, Save to iCloud Drive, Save to Web Receipts, and Save to Adobe PDF. As I do not have a printer installed, all of these other options are the only way I have to achieve "print" capability.
Thus, I believe that BrowserView.webContents.print() should do the same thing as calling window.print() from within that BrowserView: show me my system print dialog even though I have no physical printers installed.
The text was updated successfully, but these errors were encountered:
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!
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.
Preflight Checklist
Electron Version
12.0.1
What operating system are you using?
macOS
Operating System Version
macOS Mojave 10.14.6
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
Calling webContents.print() should show the system print dialog.
Actual Behavior
Calling webContents.print() returns an error (via its callback, argument 2, failureReason) "no valid printers available" because I have no printers installed.
Testcase Gist URL
No response
I have a BrowserWindow which contains "print" button, and multiple BrowserViews. I tried calling view.webContents.print() (where view == the currently active BrowserView) when the print button is clicked, however, because I have no printers installed, the callback is immediately called with success == false and failureReason == "no valid printers available".
I am aware of the following issues which have been closed but not fixed:
#25498
#24664
In the meantime, as a workaround, I am sending a message to the main script using ipcRenderer in the BrowserWindow preload script like so:
In the main script, I am listening for that message using ipcMain, and then redirecting it to the appropriate BrowserView using view.webContents.send() like so:
Finally, in the preload script for the BrowserView, I am listening for that message using ipcRenderer, and then calling window.print() like so:
This gets me the system print dialog which, despite not having any installed printers, offers me additional macOS features such as: Open in Preview, Save as PDF, Save as PostScript, Send in Mail, Add to Apple Books, Send via Messages, Save to iCloud Drive, Save to Web Receipts, and Save to Adobe PDF. As I do not have a printer installed, all of these other options are the only way I have to achieve "print" capability.
Thus, I believe that BrowserView.webContents.print() should do the same thing as calling window.print() from within that BrowserView: show me my system print dialog even though I have no physical printers installed.
The text was updated successfully, but these errors were encountered: