wails icon indicating copy to clipboard operation
wails copied to clipboard

Feature: Allow silent printing

Open cstenglein opened this issue 1 year ago • 2 comments
trafficstars

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

First of all, thank you very much for this project. :)

As a devleoper, I would like to have the option to print a page "silently", meaning without showing the print dialog. This is usually used in kiosk environments, e.g. for printing photos.

Electron already does this with the webContents.print function.

Wails only has the WindowPrint function which calls window.print (see frontend.go.

Describe alternatives you've considered

No response

Additional context

No response

cstenglein avatar Feb 15 '24 17:02 cstenglein

Great suggestion 👍 Do you know how electron implemented it? My guess is "outside the browser"...

leaanthony avatar Feb 15 '24 19:02 leaanthony

Since you are using WebView2 for the windows part, you could print silently there:

https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/print?tabs=win32cpp#the-print-method-to-customize-printing

See the Print statement:

Silently prints the current top-level document in the WebView2 using optional programmatically specified print settings to a printer. You can use this to build your own Print Preview dialog or print experience.

Do you know how electron implemented it? My guess is "outside the browser"...

The closest I can find is the Print method in electron_api_web_contents.cc, which collects the options and forwards the job to a print_task_runner_.

cstenglein avatar Feb 15 '24 20:02 cstenglein