Opening PDF file on the browser instead to start download automatically - javascript

I have been facing an issue on my code for opening PDF files. The code is:
window.open(url_pdf_file, "_blank");
The issue is:
On the same user's browser, a PDF file has been opened automatically by the browser and the user can read the PDF file on the browser, but for others PDF files the download operation has been started automatically and the browser has not been opened.
Is there a way for always opening the browser for the user?

Related

Download a file with javascript without any prompt name select, path select window

I'm generating pdf files from a html file using decktape (and ofc reveal.js) inside a docker image. In the html file there are multiple svg files, which i need to download separately.
My idea was to create a script which automatically downloads the svg-s with the computed css when the html file is opened. But I have to solve the problem of the prompt window. Is there any way to download files automatically with javascript without the prompt window popping up?
I'm already able to download the file with the prompt window popping up, but I would like to do it without that, automatically. This is happening on a Linux Debian 9 server, and the decktape is using a Chromium.

Can you prevent PDF javascript running when loaded in browser?

I ran into an interesting PDF file which has some custom javascript that triggers the print window function automatically when the file is opened.
The annoyance comes when the file is uploaded into a web app and every time the file is previewed or opened it fires up the print dialog.
The only information I found was about cleaning the file in a PDF creator/reader software or blocking the default print dialog on the page with javascript, but that seems to interfere with normal print options.
Has anyone run into this combination before and found a way to block the print dialog on PDF files (only) without disrupting the usual print options for the browser?

Chrome PDF Viewer embedded download button not working

Clicking the Chrome PDF Viewer download button directly downloading the server-side file.
I'm using ColdFusion server to generate the pdf file and view it in a separate tab with inline. PDF was correctly viewing in a tab but when clicking the download icon I can able to download that PDF file, it was downloading my .cfm file.
Try swapping 'inline' with 'attachment', in your Content-Disposition header.
Basically, inline will try, always varying by borwser, to open the file inside the browser. In any case what you're trying to do you should definitely use attachment. This will directly go to the user and force a download.

Make browser prompt for Open or Save while opening download link

I am using window.open to download a file.
window.open(urlToDownload)
The download link which I am trying to open can either be a link to a content in amazon s3 bucket or directly a link to a file in my file system.
Currently the browser is immediately downloading the content. Instead I would like the browser to show a prompt message which says either to save or open the file. My file will be in .xlsx format.

JavaScript Phonegap open PDF file

How to open PDF file without plugin?
I'm tried : window.open(path, '_blank', 'fullscreen=yes');
and opened blank page in editor.
Do you want the PDF to open inside your app, or is it OK if it's opened externally? If it's the latter:
On iOS you can just create a normal link with target="_blank" and Phonegap will open the pdf in Safari.
On Android you need to call window.open with "_system" as window name: window.open("yoururl", "_system", "location=no"); and Android will either open in the browser or start downloading (which might not be very obvious), or show the "Complete action using"-dialog if there are several options to open the file.
Of course, the downside of opening externally is that the users need to get back to your app themselves after viewing the PDF, so if you anticipate many users will view the pdf I would not recommend this solution.

Categories