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
Please, make printing work with Electron ! #17523
Comments
Just thought I'd leave some more info here. I'm having similar issues on v4.1.4 (and 4.0.x before). The print dialog will open, but only intermittently. It will open several times in a row, then not open for a while and maybe open again once or twice, but ultimately seems to stop opening altogether. EDIT: Also, tried to just force silent printing by passing |
This is out of my abilities to fix. I see it was self assigned by @brenca 2 weeks ago. I am just curious if there is any progress on these issues. Particularly in regards to using a |
Just noticed this. https://github.com/electron/electron/blob/96b32a814ceda6818f7b9e1138f7468e7767cda2/patches/common/chromium/printing.patch Looks like the issues are getting addressed. Thanks, @brenca! |
It doesn't seem so 😞 PR descrption says:
|
Hooray ! It seems that printing problems with Electron will soon be only old memories! Some problems have already been fixed in Electron |
I just tested |
@JonaMX yes, that is expected. It has not been backported to that release line yet and remains in flight; if it had you would have been able to see it in the release notes. |
It still does not work in 5.0.6. |
@craftzdog As expected. According to the releases notes this change was not pushed in 5.0.6. |
@baconbrad thx for letting me know. hope it will be pushed to 5.x soon! |
Just in case this helps someone, the only stable version which works with printing is v3.0.10. |
@ebmbook yes, it seems that the supposed fix has not been ported to any release branch. Actually this is an umbrella issue covering many more specific problems and without a chance to test this fix I'm very spectical that it fixes all of them. These issues have been dragging for quite a while and it's obvious that prining has a very low priority in the development plans. We are also stuck with v3.0.x and I don't see our project upgrading to a newer electron version any time soon. |
Same here stuck on v3 because silent printing still does not work correctly on any newer version. |
@JonaMX v5.0.7 fixes silent printing. #19598 was also recently merged and fixes a slew of issues, which y'all can test in v7.0.0-beta.2 I'll be porting portions of that fix back as soon as i can for v6 and v5. |
Thanks @codebytere I'll test this out and let you know how it went. |
Just tested our POS with v6.0.10 and most everything works with the exception when we specify a |
Don't know if this is the right place to add this but It does work when using This has been rather consistent for us since we use electron (v3). |
We also meet the same problem under v5.0.11 @barbalex |
I test the beta and it works. Thank you very much. no more printToPdf and say goodby to exec pdfToPrinter.exe with a long lagging. the process of printing the barcode label is fast now. |
Hey folks - i still monitor this issue so if you see printing issues please amalgamate them here so i can continue to chip away at printing problems! |
@codebytere how about #17523 (comment)? |
@barbalex i'll need some more info; what platform(s) is this occurring on? do you have a simple repro you know triggers the issue (ex. so i can be sure i'm testing with the config closest to the one you're having issues with) |
I just had a recent bad experienced with windows 7 with Intel Celeron CPU. it takes 10+ seconds to spool the SVG barcode generated by Jsbarcode. I now in electron 8. My workaround is by using |
@codebytere I can see this in dev and prod mode on Windows 10 ans MacOS (whatever the newest version is). Unfortunately I do not know how to build a simple repro. |
@barbalex this unfortunately seems to be an issue with chrome itself; you can see this if you create a simple webpage: <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<style>
body {
background-color: lightgreen;
-webkit-print-color-adjust: exact;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<script>
</script>
</body>
</html> and then open it in chrome and try to print it. That too is bereft of background colors. |
Yes, but:
@media print {
-webkit-print-color-adjust: exact;
} Edit: I never tried the css trick in electron. Just learned it a few weeks ago in a web project. I guess it works in electron too. But it would be nice if Edit2: I can confirm that |
I ran into an issue when calling
Is there any workaround for this for v5.0.7? |
@Hedwig188 I had this problem when trying to print immediately after opening a windows. It turned out that the events 'did-finish-load' and 'ready-to-show' sometimes come in different order. I did it like this:
|
@gozzoo I tried your solution, but still got the empty file as the result. |
@Hedwig188 you may try saving the html before printing, to make sure that there is actually something ready to be printed. If the page contents gets generated dynamically it's quite possible that at the time those events get fired the page is still empty. |
@codebytere - Thanks for your printing contributions ... seems like there was a mountain to climb here over the last few years. On Windows the option for printBackground is still ignored if you allow the user to select the printer. If you print silent and specify the printer printBackground works as advertised. Thankfully your comments above did provide me a workaround which allowed us to remove our own printer selection dialog to work around this:
|
Thx,At last it worked |
@yetianyue what worked and what didn't work before that? I'm also stuck with v.3.0 and just don't want to spend the time and energy to test if printing works with each new version. I've been keeping my hopes up for v.10. Has anywone tested printing with v10? |
For my case, the current highest working version is 2.0.18, |
I've tested with latest electron 10. Print functions working fine! |
@gozzoo I've tested with electron 10.1.5 and printing iFrame is still not working. document.querySelector("#print-iframe").contentWindow.print() freezes after a print job is queue. |
I have same problem in electron 10.1.5 and mac |
We've "solved" all printing issues by discarding electron printing altogether.
So when user clicks Print we convert HTML to PDF and just open resulted PDF in SumatraPDF. This solves missing print preview issue. Also we can print in silent mode by supplying I know it's a very hacky solution but I hope it helps. EDIT: <body>
...
<script>
window.print()
</script>
</body> |
It looks like the issues in the description have all either been fixed by @codebytere or are referring to versions of Electron that are no longer supported. Moreover, a long-running thread with the topic "Please, make printing work with Electron !" is probably not the best place to report ongoing issues, so I'm going to close this issue. The project does take printing seriously. If anyone is still seeing issues in supported versions of electron -- currently 9, 10, and 11 -- then I encourage you to report them as standalone issues. Thank you! Also, in the spirit of the devs here who have shared tips and tricks with each other, you may want to check out the project's new Discord server! It's a good place to chat with other developers who are using Electron. |
Electron missing font while print i tested electron 3.1.10 working perfecly in developement |
@ibalaji777 3.X is too out of date. A fix will never be backported since it is unsupported. You will need to use a later version. Unfortunately later versions are having regression issues. 11.X is still in the support scope and seems to be working fine for most printing issues though. |
@baconbrad In what version it realiably prints? How to print PDFs as images? |
I have a problem when working with win.webContents.printToPDF, pdf is getting generated but the text (color) is getting faded instead of my css text color, it is looks like a Gray color text with some opacity. has anyone faced this kind of issue before ? Can you please share any solutions? Thanks!! |
Problem Description
There are many printing problems since Electron 3 and this prevents people who need a working print solution to use Electron 3, 4 or 5 !
So please, can you take a look at all this printings issues and trying to fix it ? We are a lot of developers waiting for this since a long time..
Thanks a lot for your work ! And I hope you could give us some feedback about this.
cc: @codebytere @MarshallOfSound @nornagon
Related issues
All this issues seems related to
webContents.print()
which seems to be buggy:webContents.print() callback always return false #17265✔️webContents.print()
callback always returnfalse
Fix callback for webContents.print() cancel event #16085 Fix callback for✔️webContents.print()
cancel event'silent: true' for printing not working in version 5. #18123'silent: true'
for printing not working in version 5webContents.print() doesn't respond when adding parameters #18858webContents.print()
doesn't respond when adding parametersDon't ask user for print settings. #17670 Don't ask user for print settings.Silent print not working in mac/osX #16362 Silent print not working in mac/osXBetter callback value for webContents.print() #18980 Better callback value forwebContents.print()
print blurring #18917 print blurringwebContents.print()
doesn't work whendeviceName
is provided andsilent: true
Other printing issues:
Webview.print() not working properly in 4.0.X #16534webview.print()
not working properly in 4.0.XwebContents.print()
random missing lettersPrinting needs more options #7849 Printing needs more optionsAdd error information to webContents.print() callback #15568 Add error information towebContents.print()
callbackAdd an option to choose the paper format (size) on webContents.print() #19056 Add an option to choose the paper format (size) onwebContents.print()
webContents.printToPDF()
regression in v5Electron crashed after print #19108 Electron crashed after printv6.0.2
andv5.0.10
(Non-exhaustive list)
The text was updated successfully, but these errors were encountered: