Get Firefox PDF viewer information - javascript

I have a web application written in c# that shows pdf documents.
What I do is when a user click a document, I open a new browser tab and show the pdf.
Everything works fine but in Firefox i have a boring problem.
If the PDF viewing option is set to 'Preview in Firefox' goes fine, otherwise the browser downloads the aspx page where the document should be shown.
Is it possible via javascript or c# code know what option is set and so manage the situation in a proper way?

Related

JavaScript: Save PDF in the 'Microsoft PDF reader'

my web app opens a PDF inside an Iframe. Users can then add texts, draw with digital ink and highlight text. As the PDF is rendered using the user's browser-engine, I recommend trying it with the latest Microsoft Edge.
I would like to save the edited PDF to the location I opened it from with the click of a button.
The PDF editor of the browser has a save feature, but users have to select the location first, and confirm that they are overwriting the file.
Is it even possible because Microsoft Edge seems to isolate the PDF process. When I open a PDF in Edge without my web app, I can simply click the save button, and it will be saved at the location I opened it.
I could not find any documentation for microsoft pdf editor and how to interact with it.
Full code of my project: https://github.com/joseftogo/PDF-Notes-Manager-Alpha
Thank you!
I agree with KJ's opinion. When you open a pdf on a website in Edge, you're actually view it online. So it's wrong to say "save the edited PDF to the location I opened it", it's not opened from local file path. If you want to save it, you're not overwriting any file on your computer, you're downloading a new file to your computer, so you have to select the location first. It's the necessary process.
For the situation you say, "When I open a PDF in Edge without my web app, I can simply click the save button, and it will be saved at the location I opened it." I think that's when you open a local pdf file in Edge. At that time, Edge is just a viewer, and the pdf is already existed on your computer so of course you can overwrite that file directly.

Why does this URL do different things depending on how it's activated?

In a related post (here) I discuss a problem I'm having with a URL action in a SQL Server Reporting Services report. I thought I had solved the problem, but I now realize that I haven't. (I'll update the related post in due course.)
I'm generating a URL using string concatenation, and using Javascript so the URL opens in a new browser tab. Here's the code that generates the URL, which I think is pretty standard:
="javascript:void(window.open('http://www.ic.gc.ca/app/opic-cipo/trdmrks/srch/viewTrademark?id="
+ Fields!applicationNoWithExtn.Value
+ "&lang=eng&tab=reg','_blank'))"
And here's an example of the URL that's generated when a value is inserted:
http://www.ic.gc.ca/app/opic-cipo/trdmrks/srch/viewTrademark?id=159511-00&lang=eng&tab=reg
The generated URL works. It takes you to an online database web page for a Canadian trademark having application number 159511-00 (you don't see the "-00" suffix on the web page, but it's the correct application number).
The problem is that when the user clicks the generated URL, the browser's print dialog opens immediately after the web page opens. That's very distracting; the user has to click Cancel to dismiss the print dialog. If the web page is reloaded or refreshed within the browser, the browser's print dialog opens again. However, if I copy the URL and paste it into a new browser tab, I get the desired web page without the print dialog. I don't get it; it's the identical URL, but the version of the URL generated by my application somehow triggers the print dialog, whereas a copy/pasted version of the identical URL doesn't. I've tried different browsers (Chrome, Edge and IE) and different machines, but I keep getting that print dialog when I click the URL generated by my application. If I change the code to generate a standard URL like http://google.com the generated standard URL works without triggering the print dialog. So the problem seems to be with the particular web site that I am accessing via the concatenated URLs shown above.
Can anyone explain what's going on and how I can suppress that print dialog?

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.

Precache file with Javascript in the browser?

How can I do this:
the page loads
javascript loads a remote PDF file into local memory
the user clicks a button/link
the system launches the PDF reader or starts a download dialog with the PDF file already in memory
In other words, it's a regular file download in the browser EXCEPT that the file has already been loading in the background in order to speed up its receipt when/if the user decides to download the file.
You would have to encode the file (perhaps via a servlet), then you could get it through an XHR, and write it into a data uri, which you could then attach to a button or link.
This technique would probably only work on small files and very recent browsers.
StackOverflow won't let me post an example link as a link, so to test the concept, you'll have to copy the following line into an html file and see if you can load the link:
pdf link
This worked perfectly in Chrome when I tested it just now, and worked partially in Firefox. It didn't work at all in my version of IE.
Another potential solution is to make absolutely sure that the pdf is being cached, and then try to load it in a hidden iframe. Whether this works or not will depend on how the user has their browser set up.
You should consider not doing it at all, given the difficulties.

Is it possible to open a file from a shared folder outside the browser

We have a file handling ASP.Net web control used in intranet web applications, that currently uses ActiveX to handle file check-outs, and check-ins. Works fine, in IE&Win.
But now we are trying to get rid of ActiveX & IE only behavior...
If a file is checked out, it is copied to file share, with access right limited to the checking-out user.
Using a hidden iframe, and setting the src of the iframe to something like "file:////file_share/dictionary/users_stuff/someDoc.doc", an open/download dialog is shown, so the user can open and edit the shared file in Word, Excel, etc directly from the file share.
Works fine for file types browsers can't handle themselves.
But for file types like txt, images, html the browser simply loads the file to the iframe, or opens the file, if the user is given a link. And the user can't edit the file without manually launching the appropriate application and copying the url. Showing the users a "Copy this url to your preferred application, and try to edit it" would not be really user friendly...
My question is: is it possible to get the browser (without ActiveX, IE...) to pass the link to the OS, or show a "What do you want to do with this file" dialog of some sort?
If not, what and how could be achieved?
The closest I could come up with is this thread:
https://stackoverflow.com/a/1394725/1195927
#Red says no (and the original poster agrees) BUT #Daan seems to have a solution.
I have not tested, so YMMV.
If a javascript/html solution is not found, I may have an ugly hack for you . . .
See my post here: Launching a Downloadable Link

Categories