We have a pdf preview option in our company's internal back office application. At some point in the past few months or weeks, it stopped working properly in Chrome. The file comes with a header: Content-Disposition: inline; filename="foo.pdf". But instead of displaying in the embed or object tag, it downloads immediately to the configured Chrome downloads folder. This does not happen in, say, Safari, where it continues to display correctly. I can probably find some workaround, like fetching it, converting to base64, yada yada, but I'd like not to have to do that!
Related
There are some old questions regarding this topic, but the issue I'm facing is just some days old so thought to create a new thread.
I am using the content-disposition inline combined with filename to open a PDF file directly in Browser.
content-disposition: inline; filename="MyFile.pdf"
Until a couple of days ago it was working fine in Chrome and Firefox, (I know that in old IE versions the filename parameter wouldn't work in inline), PDF was opening in browser with the correct (provided) filename.
Now it seems like the filename parameter isn't working anymore even for Chrome and Firefox. The PDF is opened correctly but created with a name from the last part of the URL, which in my case is just pdf (https://.../pdf).
If I switch to attachment instead of inline the filename works fine, file gets downloaded with the correct filename. Issue is that I need to open the file in browser and not download it.
Is inline with filename not anymore possible in Chrome and Firefox?
I am facing very similar problem lately.
Strangely, when making a POST request for PDF document, the filename is ignored. But if I make a GET request, everything works like before. PDF is shown correctly and SaveAs also works with correct filename.
I ended up making a redirect on the server side, so the last request is a GET.
Another thing I noticed is, when the user clicks on the Download (Save As) button in the browser's PDF viewer, the server gets another request for the document and serves the content again. The Print command however does not make another request and prints the content already in the PDF viewer.
Hope this info helps, even if only to let you know, you're not the only one with this problem.
Edit:
It turned out, that POST and GET requests did not have anything to do with the problem. The problem was Cache-Control: no-store header that prevented the browser to store the PDF content and forced it to make another request for the PDF content at Save As command. The POST command was not formed correctly the second time which resulted in "Network Error".
I removed no-store from the header and now everything works fine.
The new header looks like this:
Cache-Control: no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0
I have found that in my environment, URLs containing basic authentication do not allow inline display of pdfs.
I noticed strange behaviour for google chrome.
I have web application based on java spring-mvc framework.
In head tag <meta charset="utf-8">is set.
For each page response headers return Content-Type:text/html;charset=UTF-8
In IE 8,9,10,11 and FF if user changes encoding in browser's settings to KOI8-R and then goes to another page inside domain - browser encoding will be automatically returned to UTF-8.
BUT in google chrome in same case KOI8-R will be present even if we go to other pages inside domain.
Is it expected behaviour for Chrome? Maybe it is some kind of bug?
Chrome doesn't like to use UTF-8 by default so you have to do:
Click the Chrome menu on the browser toolbar.
Select "Tools"
Select "Encoding".
Pick one "Unicode (UTF-8)" from the menu of encodings
To make the client do this by default you would probably have to write some script but I'm afraid I can't help you out there.
I just created this site and because I am using a Mac, I do not have IE. I have had a few people tell me that they are not able to download PDF files. That is to say, when they click on a link that is supposed to display a PDF file in a new tab, they get a "This page can not be displayed" error. I can take the same file and put it on a different website, create a link and it works fine in IE.
The link to this page is www.dallascameraclub.org. Try clicking on any Newsletter as they are all PDF's. They will produce an error in IE. Works fine in Safari, Firefox, and Chrome.
This is a wordpress site and I have never heard nor had this problem before. I have no idea why this would be the case.
Research seems to always blame IE for something or another but there are several people complaining of this when this issue never happened on the older site. Same links, same PDF's and other document types. I am a bit perplexed.
Any ideas?
Many thanks,
Houston
I have the following code in a html document:
<p>PDF sample</p>
<object data="http://www.whateverdomain.com/whatever/~/media/sample.pdf" type="application/pdf"></object>
This is working in IE, Firefox but not in Chrome. Appears a grey box in the browser with no embedded pdf. When I check on "network" tab in chrome I'm receiving a HTTP 200 response but PDF is not shown.
I tried URL encode tilde "~" symbol replacing it by %7e but still its not working on Chrome.
I don't have the possibility of changing the url which is provided by an external service.
Do you have any clue on how to solve ?
You might wish to try and use a simple iframe. At the very least I am pretty sure that works for chrome, might not work for IE though. Another alternative is using the Google Docs viewer, with that you are sure to be cross browser compatible, although some pdf's might not render perfectly. The last option you have is using something like pdf.js to render the pdf's yourself inside the browser. Gives you a lot of control and ensures that even people running computers without a pdf viewer installed (or a native pdf viewer like chrome and firefox) will be able to view the file.
I have a webpage like e.g. www.example.com/NYSE/rates. If the user decides to save the html she sees on her local disk, I want to preset the filename she gets, when she clicks "Save as", with NYSE_rates_09_12_2011.html. (Which obviously will be different tomorrow or for a different stock exchange.) Now I always get rates.html as default.
How can I do that?
It appears that in at least the latest version of the most popular web browsers on Windows (Internet Explorer, Firefox, Chrome, Safari and Opera) the default filename filled in when saving a webpage is taken from the page's <title> tag, so simply making sure the date appears in there should put you right.
As I found out, this is a known problem with Firefox, that stems from the days of Netscape Navigator. And there is an add-on "File Title" that fixes it.