-
Notifications
You must be signed in to change notification settings - Fork 51
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
SaveAs functionality #1090
Comments
Hi @jgrahovac, Not sure how to implement it is the C++. But if you have implemented already it and it is not working, it might be due to you are running application in Administrator mode. I have faced similar problem. I had WPF application where I was using SaveAs and Print functionality of WebView2, but it was not opening SaveAs dialog box. It was due to Admin mode. Hope this might help you. Happy Coding :) Thanks, |
If this is the admin/elevated issue, we are tracking that in #802. Otherwise I would expect this to just work. |
Does webview2 support |
@rgup63 No we don't support that as a WebView2 API today. Do you want me to open that as a feature request? |
@champnic Yes please, I think it would be good if webview2 supports this feature. |
Done :) |
Hi @champnic 👋 Any update on this one? It would be a very useful feature to programmatically trigger the "Save As" flow, since the The only way "Save" can be triggered, if customization is made to the context menu. Still, this is only restricted to the context menu and it's also an experimental feature as of today. Last, I think it would worth removing the Thanks in advance! |
Hi @szanto90balazs! No update on this one yet, sorry! |
This comment was marked as off-topic.
This comment was marked as off-topic.
Hello, You can use JavaScript APIs to implement SaveAs. Here is an example: var request = new XMLHttpRequest();
request.open("GET", "https://www.bing.com/");
request.responseType = "text";
request.send();
request.addEventListener("loadend", loadEnd);
async function loadEnd(e) {
const content = request.responseText;
const opts = {
types: [{
description: 'html file',
accept: { 'text/html': ['.html'] },
}],
};
const handle = await window.showSaveFilePicker(opts);
const writable = await handle.createWritable();
writable.write(content);
writable.close();
} Let us know if this addresses your scenario. |
Hello @nishitha-burman, We aim to download all the assets related to the page. If I understand it correctly, the proposed solution only downloads the HTML page, but not the other assets (CSS, JS, image files, ...) as opposed to the browser's SaveAs functionality. |
Hi @szanto90balazs, Thank you for your reply. We are currently investigating. Some follow-up questions:
Thank you, |
Hi @szanto90balazs, unfortunately, we don't have a direct API to do this right now. However if you can send input to the WebView2 window, there is a workaround. You can send a right click input and handle the ContextMenuRequested event by setting the SelectedCommandId property to the "Save As" item, which will run that command. |
@nishitha-burman I'll try to answer your follow up questions:
From the context menu, from any WPF menu which might be shared globally across webview instances or using a global hotkey
Yes.
The same formats that's offered by the "Save as" dialog triggered from the context menu.
It would be good enough to stick to the same formats provided just like Save As does. @yildirimcagri Good idea, I'll look into it. |
@yildirimcagri The workaround you suggested worked great. I was also able to override the global Ctlr+S shortcut, so I can trigger SaveAs using key bindings. This SO post helped significantly with the implementation. Some changes will be needed to it, though: https://stackoverflow.com/questions/6554494/how-can-i-send-a-right-click-event-to-an-automationelement-using-wpfs-ui-automa See code example:
Works with multiple displays as well, but the example code needs to be changed to get the screen the WebView2 is displayed on. |
Sounds good, thanks for the update @szanto90balazs. Closing this issue since the workaround works. |
We've removed the "Ctrl+S" hotkey text from the context menu, and it should be in runtime versions 105.0.1340.0+. We're also going to reopen this issue to track future improvements to invoking SaveAs. While there is a workaround that exists, it's relatively cumbersome and non-intuitive. |
@champnic thanks for integrating this feature request into this ticket. I just want to point out that the discussed work around does not work in our case, due to the save dialog that appears. |
I just want to kindly ask the following two questions: |
Hi @Mips128, This feature request is in our backlog and something we will be looking into next year. |
Hello, We are looking into this feature and I have a couple of questions:
@Mips128, @jgrahovac, @aks1008, @rgup63, @szanto90balazs Thank you! |
I am looking to build my own SaveAs dialog for HTML pages, PDF, images, video, etc |
@nishitha-burman |
Thank you for the feedback @mikkelmogensen and @donid. We are currently working on a SaveAs API and I would like to better understand your requirements. @donid are you looking to build your own SaveAs dialog or trigger the built-in SaveAs dialog? Are you also looking for an API to close the dialog? Thanks! |
@nishitha-burman |
@donid Thanks for the details. To clarify, you don't require any SaveAs dialogs (custom or built in)? |
@nishitha-burman |
Same scenario for me, can't wait for this feature! ✌️ |
@mikkelmogensen can you provide more details on your scenario for PDF, images, video? Are you looking support for a scenario where you save the whole page that contains images, pdf, video or the scenario where end user hovers over an image or pdf and do "Save-image-as"? |
@nishitha-burman I have built my own dialog window for DownloadStarting and now I am looking to build my own SaveAs dialog for complete webpage and PDF and link and image and video. Maybe some along the lines of SaveAsStarting I would also like to build my own open/upload dialog, which I don't believe is possible yet, but maybe I will have to open a separate issue? |
Edited & rewrote the entire reply: WebView2 version 1.0.1587.40 has a context menu for a Save As, which matches Edge's & has a MHTML format, so that's great so far. Question becomes how do we, or can we, access the method programmatically for the Save As so it's a silent Save As? The underlying code is there already. |
@nishitha-burman @champnic |
A TotalBytesToReceive property would be appreciated for SaveAsUIShowing event |
@mikkelmogensen Do you expect this The answer is no. Because it's out of the scope of |
Hello, the SaveAs API is now available as experimental. Please give it a try and let us know if you have any feedback! |
I'm using WebView2 in C++. How can I implement SaveAs option from right click menu? It is supposed to launch SaveAs dialog to save html file.
AB#32723386
The text was updated successfully, but these errors were encountered: