Is it possible to save a file to the users local Downloads folder without prompting them with a save as dialog?
I have an application where a user right mouse clicks to choose an option to save a specific file.
I have used IHttpHandler interface but not sure how to call this handler in code so that the system will start saving to the downloads file without the user having to navigate to a different page
One way out is to host the required file on a public URL and simply navigate to that URL in a new tab/window from your silverlight app..
HtmlPage.Window.Navigate(new Uri("<YOUR FILE's URL>"), "_blank");
This should cause the browser to open that link in a new tab and in turn download it automatically (occasionally depending on the user settings)..
Related
I'm working on an api which returns a PDF link. I can put that link into a button, and when users click on that link, it'll download a PDF to their computer. I wonder if there is a way, so that when users click on the link the first time, it'll download the file. But if they click on the link the second time, it just opens a modal with the PDF content inside of it? That way they don't have to download the file again and again.
It's confidential so I can't tell how the link look like, but it's a PDF link stored in s3 aws.
You can do it but you need to store the information that if the user clicked the button before or not. The options for storing that information is:
Local Storage
Cookie
Your backend
I would suggest not to involve your backend on this, you can just write to localStorage when user clicks that link for the first time and set something like pdfDownloadedPreviously. If you have multiple pdfs like this, you would need to define a unique key for each of them so they don't override each other.
And in your program logic, you can read this from the localStorage, if that key exists in the localStorage then you open your modal, otherwise download.
I'm using webview2 in a .NET Framework Windows Forms application to automatically upload files to a website. The site only supports uploading one file at a time and we often have to upload hundreds of files. I used java script in the webview2 to execute the steps for the upload.
My problem is that to specify the file to upload I have to interact with a file dialog box that's opens on a button click from the website within the webview. I'm currently populating the path of the file to upload in the filedialog using SendKeys, which I think is a poor process.
Is there a way that I can interact with the filedialog that is created from the website through my Windows Forms application? If so how would I get started in figuring out how to do that?
Here's more detail on what I'm currently doing:
In the webview, to begin an upload you have to click a few checkboxes to choose upload options, which has to be done every time, so I run these commands first:
await webview2.ExecuteScriptAsync($"document.getElementById('SelectedTypeId').click();");
await webview2.ExecuteScriptAsync($"document.getElementById('AutoAcceptChkbox').click();");
Then, there's a command to click an upload button, which opens a file dialog:
await webview2.ExecuteScriptAsync($"document.getElementById('uploadFile').click();");
From here, I get the filedialog and use SendKeys.Send("Filepath to file") and SendKeys.Send("{ENTER}") to populate the file path and select the file.
Once the filedialog closes I have an additonal command to click the import button to begin the import.
The issue I have is with the filedialog. It's obviously not a great process to use SendKeys to populate the path to the file. Also, I have to make the application "wait" around the sendkeys actions so that the filedialog has time to come up and close out before moving forward, I'm betting at some point there will be errors if the application isn't waiting long enough.
I have a Web Extension that occasionally deals in files -- usually by sending off a URL to the file to a remote server or by downloading the file at the user's request and shipping off the bytes to the same server.
This works fine for most use-cases, but sometimes you'll come across a site that automatically triggers a download of a file and pops open the file-open dialog for the user to handle. I wasn't able to find any documentation or filed bugs to this effect, but is there a way to register an extension to appear as a handler in that dialog?
Its currently not possible to add an icon to the file chooser dialog with WebExtensions. Feel free to open a feature request here: http://bugzilla.mozilla.org/
If you want to handle an action whenever a download occurs, you can use
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/downloads/onCreated
I have a webbrowser control in my application that is used to display pdf files that have been created in iTextSharp and are stored locally on the hard drive.
I would like to be able to navigate the file (next, previous, first, last, toc) from my application rather than using the inbuilt nav of the reader in the browser.
I have seen that you can navigate to specific pages by using
Browser.Navigate("filename.pdf#page=?);
This works the first time but when trying to navigate to a different page, it makes the browser disappear completely with no errors. However, I can reload the file without problem if I don't have the #page=? suffix on the file url though. Any ideas on this?
Alternatively, is there anyway in iTextSharp of adding something to the file to allow for it to be navigated from an external command?
All the official parameters that can be used to navigate through a PDF using parameters in the query string after the ? character are listed in a document published by Adobe: Parameters for Opening PDF Files
You already mentioned the page parameter. Another option could be using named destinations: nameddest=destination. In this case, you need to add the anchor with name destination to the file using iTextSharp.
Note that not all viewers implement these parameters. Adobe supports them in Adobe Reader and in the Adobe Reader plug-in, but there is no guarantee that they will work in pdf.js (Firefox), Pdfium (Google Chrome),... If your browser disappears when using an open parameter, you may have hit a bug in the browser or the viewer plug-in that causes the browser to crash. iTextSharp nor iText can crash a browser ;-)
There are no other ways you can navigate a PDF from an external application. The only thing you can do, is to add JavaScript to the PDF so that it always opens at the same page. This is done using an open action. I don't think this solves your problem as it would mean that you have to change the PDF file every time you want it to open at a different page.
I have link to file (Inside sharepoint list) I need always to show Save file dialog.
But some browsers starts to download file without promt.
What should be done to avoid automatic download?