tauri-apps / wry

Cross-platform WebView library in Rust for Tauri.
Apache License 2.0
3.35k stars 248 forks source link

[windows] remove "https://tauri.localhost/" from print using rust. #1300

Open OHELLEL opened 1 week ago

OHELLEL commented 1 week ago

Is your feature request related to a problem? Please describe. How Can I hide url path while print using rust without user interaction (hiding header and footer)

Describe the solution you'd like I need to be able to control print from my app completely because I need to print html content a lot in my apps, I am using electron, but I am trying to migrate to tauri but this feature is a real pain because users of my app will definitely complain if they see "https://tauri.localhost".

TheAwesome98-Real commented 1 week ago

can you explain more? this doesn't seem to make sense. if you're talking about the command-line output, the users can't see it at all.

OHELLEL commented 1 week ago

When you invoke window.print it opens the native print window which inject a script to your html and adds a header (app name) and footer (url), the user can scroll down and look for a checkbox that toggle this in the native print dialog, but its confusing for most users to see "https://tauri.local/" printed on their reports paper for no reason.

OHELLEL commented 1 week ago

I can't use jsPDF or any other pdf library because they don't support rtl languages fully but the browser have a good rendering engine when it comes to rtl languages.

I am using electron right now and it works perfectly because electron has a feature:

webcontents.printToPDF.

But distributing multiple 70mb-140mb apps (Simple apps) is kinda of annoying.

pewsheen commented 1 week ago

Hmm, if you can control the HTML of content, perhaps you can try using CSS: https://stackoverflow.com/questions/8228088/remove-header-and-footer-from-window-print

On Windows, we simply call window.print() to launch the panel, and it doesn't take any option.

OHELLEL commented 1 week ago

Setting the body margins instead of the page margins will add margin-top for the first page but not the rest (2,3,4,5 ...... Etc will have margin-top:0).

This can't be controlled using css or JavaScript.

So it essential to find away to generate pdfs directly using the webview api without the need for native print preview, this is a truly important feature for desktop apps