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
Printing needs more options #7849
Comments
You can have a lot of control of the document with CSS using @page. For copies you could just loop or repeat the print function to send it as multiple jobs. |
To summary, the things we need to add for better printing support:
|
A callback when printing is done could be nice, but I think this are the minimum options necessary to develop something that actually need to print stuff. |
Silent printing also doesn't let you select a printer. It just goes to the default printer (as seen here) --> #5572 |
The electron-printer package might be helpful. |
#8596 maybe helps |
How do I pass custom margin parameter for marginsType: 4? |
currently you can't. see: |
@zcbenz in electron@1.6.11, Perhaps if electron had an API for printing PDF's and then |
Do you have any release plans for integrating these options in
It will be nice to use these options instead of solving it via css |
Need a way to pass data directly to printer for RAW printing to thermal and label printers. The same functionality available in node-print call printDirect() |
@jasonfutch you can use node-print instead. |
Is it possible to print HTML documents with electron? A friend and I are developing a POS desktop app and need to print tickets with a generic (text only) printer. We generete tickets from dynamic HTML and use: Printing HTML pages from browser works OK but not when using Electron. We are testing on Windows 10 x64, Electron 1.7.9. |
@renaesop is there anyway at all to pass data directly to the printer in electron? I've been trying for hours to get node-printer to work on my Windows machine, and I'm having absolutely no luck. |
I really need the option to provide a page range, EG only print page 1 when using webContents.printToPDF() |
Is there a way to detect when the user cancelled the job, after calling This is what I have so far: const printOptions = {
silent: false,
printBackground: true,
deviceName: ''
};
window.webContents.print(printOptions, (success: boolean) => {
if (!success) {
// deal with the error
}
}); In the situation I described above, the callback is never triggered. |
@faviovelez Were you able to find any solution? |
@abhijithcs @faviovelez In our POS we have an element ( Depending on the type of printer we load in a style sheet with the best settings for it. Because unfortunately CSS for one printer won't work for another completely different type. Here is one for a regular A4 printer: @media print {
@page {
size: A4;
}
body * {
visibility: hidden;
}
#printer-content, #printer-content * {
visibility: visible;
}
#printer-content {
position: absolute;
left: 0;
top: 0;
}
} Or a Star receipt printer: @media print {
@page {
margin: 0;
}
body * {
visibility: hidden;
}
#printer-content, #printer-content * {
visibility: visible;
}
#printer-content {
position: absolute;
left: 0;
top: 0;
width: 71mm
min-width: 71mm;
max-width: 71mm;
font-size: 12px;
font-family: "Courier New", Courier !IMPORTANT;
font-weight: 700;
}
} |
I'm wondering about the same as @hicaro does, i.e. when the user cancels the print dialog there's no callback. This is troublesome, as I would like to know when the print dialog closes. |
Repeating the printing function does not work for tag printers (like Zebra printers). The printer expects either the quantity of tags to print them all at once, or a cooldown between different tasks. Repeating the printing task actually makes each repetition a different printing task, thus requiring a timeout for each one. |
@JorgeHawkins Yes but this is a problem with the printing drivers. |
No, it isn't. Why can a native app print many tags properly through these kind of printers, but Electron apps have to repeat the process one by one? Makes no sense to make the driver the culprit over an incomplete implementation of a functionality. |
@JorgeHawkins i still don't understand fully what you are talking about exactly. Can your print a normal website with the normal chrome browser print dialogue many times on your zebra without any issues? |
@JorgeHawkins I think what you are asking is already in Chrome. Could you introduce page breaks to solve this? This would allow you to send one job but have it print on separate pages, or in this case tags. |
If it helps, our workaround for the issue was to printToPDF multiple pages, the merge them together as a single PDF (it's pretty fast) and then print the merged PDF file from the command line using CUPS on Mac, and an external EXE File on Windows. We're printing on Brother and Dymo label printers. But found the same massive delay if we send multiple print jobs to the printer as opposed to a single print job with multiple pages. |
@zcbenz Chromium supports headers and footers via some extra arguments. They can be used in puppeteer (googles headless node package for chrome):
|
Is there any support or plan of support for the "Scale" function? |
@selabie68 you can achieve scaling by using css: @media print {
html, body {
zoom: 150%;
}
}
nevertheless, a setting would be great. |
Thanks @philipparndt I will test this method. Does it have the same effect as the Chromium scale option? |
hello @zcbenz , can you please let me know if I can print multiple copies without looping for print counts? Thanks in advance. |
1- There are only 2 options when it comes to print: silent and printBackground, there are plenty more options, like margins, copies, etc in the print window (Ctrl+P), that could be sent using webContents.print()
2- Access to print queue, to know if the printer is printing
The text was updated successfully, but these errors were encountered: