tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[feat] Silent print API

Open ibalaji777 opened this issue 2 years ago • 5 comments

Describe the problem

Window.print() alternative

Describe the solution you'd like

More printer options Margin and size no of copies

Alternatives considered

Window. Print()

Additional context

Native printer option margin and size select specific printer

ibalaji777 avatar Oct 02 '22 19:10 ibalaji777

What OS are you using?

amrbashir avatar Oct 03 '22 15:10 amrbashir

Windows 10 os

ibalaji777 avatar Oct 06 '22 19:10 ibalaji777

I am not sure what you want exactly because the issue title says something but the body says another. Anyways window.print() provides options to choose margins, number of copies, size...etc

image

amrbashir avatar Oct 07 '22 11:10 amrbashir

Actually I don't want dialog for every time i print

ibalaji777 avatar Oct 07 '22 13:10 ibalaji777

This is a great idea. Most printing needs to be done silently

moom-en avatar Oct 11 '22 05:10 moom-en

Hi, can I give this a try?

ong-yy avatar Oct 19 '22 14:10 ong-yy

@Ian-Yy yeah sure, thanks!

amrbashir avatar Oct 19 '22 16:10 amrbashir

Any solution?

ibalaji777 avatar Nov 02 '22 08:11 ibalaji777

Hi, sorry for taking so long. I was working on this in Linux at first but found out I can't cross build it to Windows and took more time setting the project up in Windows.

After checking things through, I found out that print function is calling an API in the wry lib which further just execute the following window.print() as JS in Microsoft Edge WebView2 as shown here. Furthermore, I found that the Microsoft WebView2 is implementing a native way of printing as well here with silent print supported on experimental now.

So, I am not so sure too where to fix this. Perhaps, a PR is required on the wry side to implement the experimental print function first?

ong-yy avatar Nov 08 '22 18:11 ong-yy

I can't answer your question. But one thing to that part:

So, I am not so sure too where to fix this. Perhaps, a PR is required on the wry side to implement the experimental print function first?

We can't use experimental apis in wry. webview2-com doesn't support it and users would have to install non-stable webview2 runtimes (and manually set the runtime path). Edit: "non-stable runtime" means a non-stable (like canary) release of Edge afaik

FabianLars avatar Nov 08 '22 18:11 FabianLars

But maybe @wravery has an idea here how we could fast-track this...

nothingismagick avatar Nov 08 '22 23:11 nothingismagick

I think @FabianLars summed it up pretty well, it's best to wait for the API to be promoted to stable.

There is a small distinction between the WebView2 SDK and the runtime that's installed, they can be updated independently. Typically, the runtime self-updates, and as long as it's new enough it'll support all of the features in the pre-release SDK. If you don't mind using experimental status APIs, you can usually just update the SDK to unlock them earlier.

In this case, that would mean updating the webview2-com crate and wry, but probably hanging back on the windows-rs versions because of the MSRV requirements in the latest version of those crates. The dependencies would get pretty complicated if we wanted to update just the WebView2 SDK version and expose the experimental APIs.

wravery avatar Nov 09 '22 17:11 wravery

closing in favor of #4917

amrbashir avatar Dec 09 '22 16:12 amrbashir

I am looking forward to the silent printing API, because my app needs this API to print small tickets and price tags

ihekui avatar Jan 09 '23 14:01 ihekui

@ihekui , @ibalaji777 Have anyone found the solution for this?

dev-itzarun avatar Feb 13 '23 09:02 dev-itzarun

I found that the Microsoft WebView2 is implementing a native way of printing as well https://github.com/MicrosoftEdge/WebView2Feedback/issues/1331 with silent print supported on experimental now.

Well, this is now stable

alimehasin avatar Feb 13 '23 10:02 alimehasin

I'm creating an order management system, but until everything stabilizes... I'll continue using electron.

noearaujo avatar Mar 02 '23 08:03 noearaujo

Hi Guys, hope you doing well, any update on this?

dnguyenfs avatar Apr 24 '24 14:04 dnguyenfs

Actually I badly need this , but seems there is no solution till now 😞...

dev-itzarun avatar Apr 24 '24 16:04 dev-itzarun

Can we use this Rust libs with js ?

  1. https://crates.io/crates/escpos

  2. https://crates.io/crates/recibo

I Dont much knowledge in RUST

dev-itzarun avatar May 15 '24 20:05 dev-itzarun