I have enabled Chrome PDF Viewer but the PDF files are still being downloaded. How do I stop this and view these PDF files within Chrome?
<embed src="http://test.com/cool.pdf" width="500" height="750">
this will embed a pdf in your html. chrome and other browsers would show the pdf as a part of the page. Thus browsers won't download it.
Related
I am using embed tag to display pdf from a web src just like this
<embed src={'http://www.somePDF.com/file.pdf'} type="application/pdf" width={"100%"} height={400} />
the problem is that in Safari is displaying the pdf correctly but in chrome is automatically dowloaded and I cannot see it in the page, for more details i am using react.js
From Mozilla (FireFox)
Keep in mind that most modern browsers have deprecated and removed support for browser plug-ins, so relying upon <embed> is generally not wise if you want your site to be operable on the average user's browser.
For current view on the relationship by chromium see https://bugs.chromium.org/p/chromium/issues/detail?id=1257611
A pdf is application/executable binary (like docx with macros) i.e. may contain JavaScript. A secured browser should not run a pdf it should offer to ignore or download it to a sandbox for neutering.
How a PDF should be displayed in a secure browser, based on Chrome code base.
We have an app which launches Electron browser. In the Electron browser we load a third party website which has a link.
When we view this site in the Chrome or IE browsers, clicking on this link it renders a PDF in an iFrame but for electron browser it shows a save file dialogue. We want to display this PDF in the electron browser just the same way it works for Chrome and IE. As it is a third party website we don't have control over rendering or loading PDF file or we are not getting any events related with loading of this PDF.
For this scenario, if there is no way to display PDF in electron then it is OK to block it so the Save file dialogue will not show.(This app is actually in the KIOSK so we don't want to save a file if it doesn't render in browser.)
Thanks in advance for your comments!
Here is a discussion on an issue almost identical to yours. The answer does a decent job explaining why the download option is appearing. As for preventing the pdf from being downloaded, try using the <embed> tag as it detects compatibility. So embed the pdf using that tag and then load the html into the <iframe>. Here is some example code and description of how to set that up.
I'm trying to display a base64 encoded pdf. In FF and Safari the code below displays the pdf in a viewer, however in Chrome the page loads, space is created for the iframe, but the iframe doesn't display.
<apex:page controller="SomeController">
<apex:iframe src="data:application/pdf;base64,{!pdf}"></apex:iframe>
</apex:page>
I have verified that I can indeed view PDF files in Chrome on other webpages and that the Chrome PDF Viewer plugin is enabled.
This ended up working, though our dev team swears that when this was tried initially it didn't work:
<apex:page controller="SomeController">
<object>
<embed src="data:application/pdf;base64,{!pdf}" height="800" width="1200"/>
</object>
</apex:page>
Of course there is the issue that object isn't supported in earlier versions of IE, but at least it works in chrome now.
This worked for me with angular js
<embed ng-src="{{NewDocumentData_PDF}}" height="800px;" width="100%;" />
When I click on a link in a page, a PDF opens. I need to validate the contents of this PDF file using Selenium in C#.
I'm able to handle this in Firefox 25(using pdf.js). In firefox, the contents of this pdf are displayed in html and hence, using isTextPresent, I am able to validate if the pdf contents are correct.
But, though Chrome opens the pdf in my browser, it does not show the pdf contents as separate elements. Is there any plugin/ setting change that can be done for me to view the pdf as html in Chrome browsewr
PDF.js is also available for Chrome - see PDF Viewer in the Chrome Web Store.
I suggest to load the PDF using the following URL: chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/content/web/viewer.html?file=<URL-encoded version of PDF file's location>.
The reason for explicitly putting the URL as shown before is that if the PDF url is visited before the extension is loaded, then the default PDF behavior is triggered (in Chromium, the file is downloaded, in Chrome, it's displayed using Chrome's built-in PDF Viewer).
After the PDF.js is loaded, you can directly type the URL for a PDF file in the omnibox, the extension automatically detects PDF files and renders the result (based on MIME-type).
I am POSTING a form to an IFRAME (target) which returns a PDF (content-disposition=inline;filename="x.pdf").
This works with current Chrome and Firefox and the embedded PDF viewer.
The only problem is, that Chrome is not able to save the PDF (it tries to save x.html with no content) (with Ctrl+S and with the icon in the PDF toolbar).
Any ideas?
Actually, it is a limitation from native Chrome PDF Viewer. You cannot save PDF file when it is displayed from an iframe using Chrome PDF Viewer (plugin).
Using Adobe Reader plugin for Chrome works perfectly.
Cheers