Skip to content
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

[feat] Provide print API #4917

Open
alimehasin opened this issue Aug 12, 2022 · 23 comments
Open

[feat] Provide print API #4917

alimehasin opened this issue Aug 12, 2022 · 23 comments
Labels
priority: 2 medium scope: core Core packages of Tauri status: backlog Issue is ready and we can work on it type: feature request

Comments

@alimehasin
Copy link
Contributor

Describe the problem

Tauri lacks a print API and this make it very difficult for electron based apps that perform lots of work with printers to migrate to Tauri, there are many use cases

  1. Unable to print a page if it is hidden visible: false (window.print() triggered automatically after page load)
  2. Unable to close the page after the printing dialog is closed (I haven't found any way to know if the dialog still open)
  3. Unable to perform silent printing

Describe the solution you'd like

Provide print API

Alternatives considered

At least I hope to see an event the get fired when the printing dialog closed

Additional context

I have seen Print to Printer and related options checked in this issue
But electron has rich API regarding to printing comparing to Tauri

@alimehasin
Copy link
Contributor Author

Unable to close the page after the printing dialog is closed (I haven't found any way to know if the dialog still open)

It turns out that there is a JS event called afterprint that will solves this problem, you can read more about it here

@rizwan92
Copy link

rizwan92 commented Dec 9, 2022

@alimehasin how this event afterprint will fix the printing in tauri ? i am very curious to know because i am facing this problem for very long , i am not able to launch my application because of printin . many people are trying to figure out how this process will help in providing print solution for tauri

how this event will tell how may printers are connected to the system?
how this event tell which printer is default printer
how to stop print dialog in chrome
how to adjust the margin and custom print settings by this event ?

@alimehasin
Copy link
Contributor Author

Hello @rizwan92, the afterprint event won't fix these issues, it will only fix one problem which is

Unable to close the page after the printing dialog is closed (I haven't found any way to know if the dialog still open)

As quoted in my previous comment

@rizwan92
Copy link

rizwan92 commented Dec 9, 2022

I do not know why this issue's priority is medium. It is a very essential part of building a desktop application. I really want to launch my application using Tauri

@Beanow
Copy link
Member

Beanow commented Dec 9, 2022

@rizwan92 Tauri is an open source project depending on it's contributors.
If you need this feature urgently, maybe you can help get the ball rolling?

For example by finding out the cross platform support by the underlying webviews for printing, and seeing what the common ground is?

Referencing https://tauri.app/v1/references/webview-versions/ if you need more insight in the webviews.

@ihekui
Copy link

ihekui commented Jan 9, 2023

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

@rizwan92
Copy link

@Beanow I could not find any cross-platform solution for webviews. I tried writing my own solution in rust but it is way too hard for me I think I need to practice more rust first to get it done. i will open the source code so other can get help and contirbute

@noearaujo
Copy link

Now it's stable: MicrosoftEdge/WebView2Feedback#1331

@Bukmopbl4
Copy link

Now it's stable: MicrosoftEdge/WebView2Feedback#1331

Let me understand, is this functionality not yet available in Tauri? Is the problem currently unresolved?

@FabianLars
Copy link
Member

Correct, it's still unresolved. This is also why this GitHub issue is still open :)

@FabianLars
Copy link
Member

I opened a tracking issue in our plugin repo where this feature will be implemented at some point: tauri-apps/plugins-workspace#293. Please do not take this as a "We'll implement this feature now", this is just me trying to get the ball rolling.

@alfianlensundev
Copy link

alfianlensundev commented Jun 15, 2023

To perform a silent print, you can use plugin Tauri Plugin Printer. However, currently, it only supports Windows.

@wcldyx
Copy link

wcldyx commented Sep 23, 2023

要执行静默打印,您可以使用插件 Tauri 插件打印机。但是,目前,它仅支持Windows。

However, it must send files in PDF format, and its printing function is not as good as "electron".

@wcldyx
Copy link

wcldyx commented Sep 23, 2023

Is there a good solution now? I need to silently print an entire long webpage.

@juancarlosgzs
Copy link

juancarlosgzs commented Dec 17, 2023

The only thing keeping my team away from Tauri is this issue, is there any ETA, attempt or desire to actually implement this?

@FabianLars
Copy link
Member

ETA?

No.

attempt?

Nothing recently that i know of.

desire?

Yes, otherwise we would close this issue.

@dev-itzarun
Copy link

dev-itzarun commented Feb 27, 2024

Is there any solution for this now , Any plugins ?

I think Webview2 actually have Methods For this : webviewPrint

@Lerado
Copy link

Lerado commented Mar 5, 2024

Ok I think I'm kinda stucked by this lol.

Please, is it at least possible to use native window.print() with a html visible content ?

@FabianLars
Copy link
Member

As far as i know window.print() should work.

@Lerado
Copy link

Lerado commented Mar 5, 2024

As far as i know window.print() should work.

Ok I think that would be a workaround for now. Thank you for the good work there. Glad I bet on Tauri when it started back in the days xD.

@dnguyenfs
Copy link

any progress on this guy? this seem to be critical problem already?

@bforbiggy
Copy link

This is really important, I can't use tauri until this is developed

@Bukmopbl4
Copy link

I'm concerned about this issue as well. For now, where I need to use silent printing, I use Electron. As far as I know, you can print using window.print() if the standard print dialog doesn't bother you. You could also go the extra mile with POS commands on the printer or write a printing module in another language, integrate it into a Tauri binary, and pass the necessary data for printing to it. All options seem to be a bit of a hassle if you need to print HTML receipts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: 2 medium scope: core Core packages of Tauri status: backlog Issue is ready and we can work on it type: feature request
Projects
Status: 📬Proposal
Development

No branches or pull requests