electron / electron

:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS

Home Page:https://electronjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Can not print contents of browser window silently in Ubuntu linux

saugatdai opened this issue · comments

Preflight Checklist

Electron Version

18.2.3

What operating system are you using?

Ubuntu

Operating System Version

Ubuntu 20.04

What arch are you using?

x64

Last Known Working Electron version

none

Expected Behavior

I want to print the contents of browser window silently on a POS printer. The code attached at Gist section works fine on windows, but doesn't work in Ubuntu. My targeted platform is ubuntu linux 20.04 and above

Actual Behavior

The output at the console for the Gist is :

Console ready 🔬
Saving files to temp directory...
Saved files to /tmp/tmp-17209-xBE03rN99Kka
Electron v18.2.3 started.
libva error: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
[19927:0702/212214.938092:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
[
{
name: 'DCP-7030',
displayName: 'DCP-7030',
description: 'Brother DCP-7030',
status: 5,
isDefault: false,
options: {
copies: '1',
'device-uri': 'usb://Brother/DCP-7030?serial=000D0N969645',
finishings: '3',
'job-cancel-after': '10800',
'job-hold-until': 'no-hold',
'job-priority': '50',
'job-sheets': 'none,none',
'marker-change-time': '0',
'number-up': '1',
'printer-commands': 'none',
'printer-info': 'Brother DCP-7030',
'printer-is-accepting-jobs': 'true',
'printer-is-shared': 'true',
'printer-is-temporary': 'false',
'printer-location': 'embeddedSaugat',
'printer-make-and-model': 'Brother DCP-7030, using brlaser v6',
'printer-state': '5',
'printer-state-change-time': '1651417533',
'printer-state-reasons': 'paused',
'printer-type': '4164',
'printer-uri-supported': 'ipp://localhost/printers/DCP-7030',
system_driverinfo: 'Brother DCP-7030, using brlaser v6'
}
},
{
name: 'POS80QMS',
displayName: 'POS80QMS',
description: '80mm printer for QMS Project',
status: 3,
isDefault: true,
options: {
copies: '1',
'device-uri': 'usb://Unknown/Printer',
finishings: '3',
'job-cancel-after': '10800',
'job-hold-until': 'no-hold',
'job-priority': '50',
'job-sheets': 'none,none',
'marker-change-time': '0',
'number-up': '1',
'printer-commands': 'none',
'printer-info': '80mm printer for QMS Project',
'printer-is-accepting-jobs': 'true',
'printer-is-shared': 'false',
'printer-is-temporary': 'false',
'printer-location': 'holus',
'printer-make-and-model': 'POS-80',
'printer-state': '3',
'printer-state-change-time': '1655307054',
'printer-state-reasons': 'none',
'printer-type': '2248708',
'printer-uri-supported': 'ipp://localhost/printers/POS80QMS',
system_driverinfo: 'POS-80'
}
}
]
(node:19895) electron: Deprecation Warning: getPrinters() is deprecated. Use the asynchronous and non-blocking version, getPrintersAsync(), instead.
(Use electron --trace-warnings ... to show where the warning was created)
failed
[19895:0702/212216.612479:ERROR:print_view_manager_base.cc(85)] Invalid printer settings The selected printer is not available or not installed correctly.
Check your printer or try selecting another printer.

Electron exited with code 0.

Testcase Gist URL

https://gist.github.com/saugatdai/5ba400d42e3fa4be66d323b2d826fe50

Additional Information

My project is not going to production because of this problem. Please help with some solutions and suggestions.

@saugatdai thanks for asking i did read your error message and found the relevant part i spotted

(node:19895) electron: Deprecation Warning: getPrinters() is deprecated. Use the asynchronous and non-blocking version, getPrintersAsync(), instead.

fix that first so use getPrintersAsync then post the error again if there is any

cheers.

First of all thank you for the response.
I've tried using the asynchronous and non-blocking method getPrintersAsync(), but got the same kind of error. Although there is no deprecation warning. Please have a look at the output :

Saving files to temp directory...
Saved files to /tmp/tmp-33593-DX2qLSVPTkIt
Electron v18.2.3 started.
libva error: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
[59037:0703/122307.756333:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
[
{
name: 'DCP-7030',
displayName: 'DCP-7030',
description: 'Brother DCP-7030',
status: 5,
isDefault: false,
options: {
copies: '1',
'device-uri': 'usb://Brother/DCP-7030?serial=000D0N969645',
finishings: '3',
'job-cancel-after': '10800',
'job-hold-until': 'no-hold',
'job-priority': '50',
'job-sheets': 'none,none',
'marker-change-time': '0',
'number-up': '1',
'printer-commands': 'none',
'printer-info': 'Brother DCP-7030',
'printer-is-accepting-jobs': 'true',
'printer-is-shared': 'true',
'printer-is-temporary': 'false',
'printer-location': 'embeddedSaugat',
'printer-make-and-model': 'Brother DCP-7030, using brlaser v6',
'printer-state': '5',
'printer-state-change-time': '1651417533',
'printer-state-reasons': 'paused',
'printer-type': '4164',
'printer-uri-supported': 'ipp://localhost/printers/DCP-7030',
system_driverinfo: 'Brother DCP-7030, using brlaser v6'
}
},
{
name: 'POS80QMS',
displayName: 'POS80QMS',
description: '80mm printer for QMS Project',
status: 3,
isDefault: true,
options: {
copies: '1',
'device-uri': 'usb://Unknown/Printer',
finishings: '3',
'job-cancel-after': '10800',
'job-hold-until': 'no-hold',
'job-priority': '50',
'job-sheets': 'none,none',
'marker-change-time': '0',
'number-up': '1',
'printer-commands': 'none',
'printer-info': '80mm printer for QMS Project',
'printer-is-accepting-jobs': 'true',
'printer-is-shared': 'false',
'printer-is-temporary': 'false',
'printer-location': 'holus',
'printer-make-and-model': 'POS-80',
'printer-state': '3',
'printer-state-change-time': '1655307054',
'printer-state-reasons': 'none',
'printer-type': '2248708',
'printer-uri-supported': 'ipp://localhost/printers/POS80QMS',
system_driverinfo: 'POS-80'
}
}
]
failed
[59004:0703/122309.367421:ERROR:print_view_manager_base.cc(85)] Invalid printer settings The selected printer is not available or not installed correctly.
Check your printer or try selecting another printer.

Electron exited with code 0.

My Public Gist for the output : https://gist.github.com/saugatdai/5ba400d42e3fa4be66d323b2d826fe50

This issue appears to be specific to setting the pageSize on Linux. In the meantime, if you don't use that property, things should work fine. I'll look into fixing the pageSize issue!

@codebytere Seems to work without any error.. I haven't tested on the actual printer. I will try it out on the printer and update it soon..

Thank you!!