Web, Silverlight. Always show save file dialog when user try to download file - silverlight

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?

Related

How do i open a local pdf file in the browser with the download option

I want to open a PDF file in the browser but instead of opening, it is downloading. I do not want to change the default settings of the browser.
If there any PDF viewer package which is easy to use, please refer.
I tried like this
first import the pdf
import Pdf from "../../../assets/pdf/abc.pdf";
then tried to open it like this
<a href={Pdf} target="\_blank" className="btn"\>Learn More</a>
But it is downloading the file. But I want to open it.
If you are using Chrome browser, select the three vertical dots in the upper-right corner.
Choose Settings > Advanced > Privacy and security. Select Site Settings > PDF documents.
Use the toggle switch next to Download PDF files instead of automatically opening them in Chrome to turn the feature on and off.
As a user you have full control, as a server you can only request the user follows your desires, but they do not have to.
A PDF application/pdf mime file is a potential source of exploit so just like a user can change settings to block adverts or images they can also block unsolicited display of a PDF.
The browsing client may choose to download and view or download only or do not download it is the same in Mozilla or Chromium, just different plugins.

How to open a generated file on Vaadin Flow?

On my app I want to open a generated PDF with PdfBox on a new tab, I have seen a couple of documentations but they are for old version of Vaadin or won't work in my case. I don't want to save it on the server or attach the file to any link or button, I want to write a method to automatically open it on a new tab.
PdfBox gives an option to save the file on an OutputStream, is there any way to open that OutputStream file on a new tab? Or at least download it without attaching it to an Anchor widget like Flow Viritin does?
The problem lies in the fact that because you don't want to save the file on the server, you cannot then have a direct url of said file to link to. You also cannot pass the pdf file as parameter to another View.
The solution is to store the pdf in the VaadinSession (as byte[] is probably easiest), and when the user then opens another tab by clicking a certain anchor/routerlink, that view will read the pdf from the VaadinSession and add the it to the view. (How to display pdf with Vaadin 14). Please remember to remove the pdf again from the VaadinSession :)

Invoke File save as prompt while Downloading in ExtJS

I want to invoke the file save as prompt while allowing the user to download a file in ExtJS from a URL.
Basically the idea is to allow the user to change the file name and select his desired location before saving the file on their machine.
Is there any way I could do this?
I do not want to use:
A server side code to send the headers.
Nor do I want to use the Flash-based Downloadify library to do this.
Also, <a> tag's "download" attribute does download the file, but it does not prompt the dialog box if the browser settings are not set right.
Is there any way apart from the above where we could handle the file download in our application?
No, it cannot be done with javascript alone due to the security restrictions of the contemporary browsers. You can read files but I have no knowledge of a way to save files directly from the javascript alone.
If your "I do not want tos" are not that strict, here you can find an example of file downloading. The essence is to send "Content-Disposition: attachment" header.

Access Specific PDF Page in WPF WebBrowser Control

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.

How does the .gdoc format work?

If you work with Google Docs your first file format is .gdoc / .gsheet / .gwhatever
What I want to understand is, how this file format works. When you open a .gdoc you basically open the browser and go to a specific URL. So is a .gdoc just a .html-file with a changed file extension?
I would like to build something similiar: A rich-text-editor which saves the content in my own file format, that you can download and if you open the file, the browser opens and links to a specific URL.
BTW: I opened a .gsheet in a text editor and found this source code:
{"url": "https://docs.google.com/a/test.com/spreadsheet/ccc?key=01234567898765432123456789&usp=docslist_api", "resource_id": "spreadsheet:0A12345B678HJK9TZPL9078767"}
*Changed the URL a bit ;)
.gdoc and .gsheet files don't contain html, but JSON. These extensions are usually linked to the Google Drive application, which just reads the file and opens the URL with your standard browser.
If you're going to implement something like this yourself, you can go the same route: let the user install a program that handles your own files and start e.g. the browser.
Another way is to just use standard shortcuts; or use can use html files (maybe with another file extension if you link this extension to the standard browser) which just redirects to your target url.
in response to your comments:
to create a simple shortcut, you'll have to generate a file with the following content:
[InternetShortcut]
URL=your.url.com
and save it as YourFileName.YourExtension.url. Note that the "real" file-extension is .url. When saved to disk, windows explorer will usually hide the .url part (regardless of the Hide known file types setting). When the user starts this file, it will just open your.url.com. Chrome provides an API to create and save files client-side, but I don't know about other browsers. Probably you'll have to use a third-party library for creating the files (if you want to do this client-side).
Note this is a Windows-only solution. I don't know how you would handle this on Mac OS.

Resources