Which is the right/best tag to use in my HTML file when I want to display the Adobe PDF viewer? Right now I'm using the code below, but there are weird side effects (e.g. it seems to steal the starting focus that I've set to another INPUT text box; it doesn't seem to play real well with the jQueryUI Resizeable class; etc.)
<embed src="abc.pdf" type="application/pdf" />
Could I even do the same thing with the OBJECT tag? Are there advantages/disadvantages to using one tag vs. the other?
Probably the best cross browser solution for pdf display on web pages is to use the Mozilla PDF.js project code, it can be run as a node.js service and used as follows
A tutorial on how to use pdf.js can be found at this ejectamenta blog article
You could also use the iframe method, although this is not cross browser compatible (eg. not working in chromium or android and probably others -> instead prompts to download). It works with dataURL's and normal URLS, not sure if the other examples work with dataURLS (please let me know if the other examples work with dataURLS?)
OBJECT vs. EMBED - why not always use embed?
object
is the current standard tag to embed something on a page.embed
was included by Netscape (alongimg
) before anything likeobject
were on the w3c mind.This is how you include a PDF with
object
:If you really need the inline PDF to show in almost every browser, as older browsers understand
embed
but notobject
, you'll need to do this:This version does not validate.
Embed is not a standard tag, though object is. Here's an article that looks like it will help you, since it seems the situation is not so simple. An example for PDF is included.
Some other options: