How to view PDF or DOC file in Browser without <iframe> tag - html

I am using HTML with JSF application in my project and also used ClickJack filter option. First I try iFrame, Object, embed for view pdf portion. I refer path in tomcat folder
<iframe src="/path/file.pdf"/>
at the time browser to show error message is To help protect the security of information you enter into this website,
the publisher of this content does not allow it to be displayed in a frame..
So I need any other way to display pdf or doc file in browser is possible?

Chrome, Edge, and other modern browsers can read PDF files within the browser natively. If you use a link like so:
My PDF
It should open a window like this:

Related

embed does not open a document in Chrome

My Blazor web application needs to display a pdf document. It works in Firefox, but not in chrome. Here is the code:
<embed src="data:application/pdf;base64,#QuoteModel.Base64EngineeringDrawing" style="overflow:auto;width:800px;height:1000px" />
The document is stored in the variable Base64EngineeringDrawing.
Here is how it looks in Firefox:
But in Chrome it is empty. The inspection shows
Replacing embed with iframe does not help.
How can this be fixed?
The correct use of iFrame is along the lines of
<iframe height="500" width="500" src="http://google.com"></iframe>
Note the separate terminator that is not the one used for <embed />
When using Iframe with embedded datauri: there can be server system and client browser limitations so first test a file under 10KB and then again ensure a test file is under 1.5MB as those can be common hurdles/blockers.
For PDFs especially as application format, every browser handling of PDF data is different depending on html construction and user settings. Hence the recommended method is provide an optional image of preview thumbnail with <a href="filename link" for download as inline viewing is down to the client preferences.
Usually my settings in Edge and other browsers is ask, what to do with incoming PDF
In Firefox on Windows an iFrame with base64 data should offer options like this
Edge may not offer user control, when its set to default PDF viewer and may display the frame instantly
If I use Palemoon or Waterfox (Firefox based) the frame is blank as I prefer for most PDF downloads and opens either inline or off line in SumatraPDF (depending on page construction)
different constructs may behave differently in recent Firefox as there was a security related change around/after version 97.

is it possible to make an hyperlink to only download a pdf file?

I have an hyperlink to a pdf form that can not be opened by the browser's pdf viewer. If clicked, the browser tries to show it but I get the error message like "it is necessary Acrobat Reader 8.x" etc. Is there a way to force an hyperlink to such pdf form file to only allow its downloading? In this way, the user could open it with his local Adobe Reader.
Let’s say you have a PDF that you want to let people download. The file will be like this:
Download Receipt
In most browsers, clicking on the link will open the file directly in the browser.
But, if you add the download attribute to the link, it will tell the browser to download the file instead.
<a href="/path/to/your/receipt.pdf" download>Download Receipt</a>
The download attribute works in all modern browsers, including MS Edge, but not Internet Explorer.
In the latest versions of Chrome, you cannot download cross-origin files (they have to be hosted on the same domain).
To make the hyperlink to download the pdf file when clicked, you should use download property inside the anchor tag. For example you can see the code below:
Download the pdf file
You can also give your own name to the downloadable pdf file in the download property that I provided as 'Document' in the code above.
Yes, it is possible. First download the file and then you'll see a link when it downloaded(it disappears quite quickly) just copy it and use:
hyperlink

How to load a PDF file embeded in an iFrame on electron browser

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.

Is it possible to display an .xls file in an <object> html tag?

For a CMS-like web app we are writing, we need to show a preview of an Excel file.
We try with the <object> tag, setting the data attribute like this:
data = "myFile.xls"
but we didn't succeed. The page, in IE and Chrome, alert that we don't have the necessary plugin, even if we have Office installed.
Does anyone have any experience in such a task?

Why people use <object classid=""> to show PDF instead of src="1.pdf"

What's the difference?
The object tag is to embed the PDF inside the browser, so the user can browse the PDF content inside the browser.
The normal link would force the user to download the pdf and read it with an another software.