1

I want to show pdfs in certain pages on my site. I've experimented with google's viewer api and it works great but I dont want to depend on a third party api call. I also want it to be as robust and reliable as possible, so I'm trying to avoid javascript. I see some indication that it can be done with just HTML using either or tags, but there appears to be disagreement as to the browser support: Recommended way to embed PDF in HTML?

Is there a definitive way to do this?

I need to support IE8+ and the site will be responsive, so the solution has to be able to accommodate smaller screen sizes.

Attention duplicate police: The entire basis for this question is to figure out what is specifically NOT answered in the other question. I even linked to that question in my ow

Community
  • 1
  • 1
emersonthis
  • 32,822
  • 59
  • 210
  • 375

1 Answers1

2

If you don't want to use JavaScript -- no, there is not. Even if there is a good enough solution for some OS with something like Acrobat Reader installed (maybe you get lucky with Windows), all the other OSes still don't support it.

So, if you want your site to be seen more or less the same way by everybody, you'll have to go with Javascript base things and their not so robust and reliable support -- they are pretty portable, that's a great thing on the web.

Related:

Community
  • 1
  • 1
Elias Dorneles
  • 22,556
  • 11
  • 85
  • 107
  • 1
    I don't deny anything you said. But can you elaborate a bit on why `` or `object` don't actually work the way some people think they do. Maybe what I'm asking is: which browsers won't support it? – emersonthis Jun 21 '13 at 01:49
  • 1
    The point is that it's not just a browser thing, it also depends on the OS and the user. For example, if the default application for handling PDFs is set to be Acrobat or Evince, the browser won't even try to display the file using the embedded viewer (which in Firefox case is Javascript based, anyway). – Elias Dorneles Jun 21 '13 at 02:41
  • 1
    And a little more elaboration, thinking that it is done with "just HTML" and no JavaScript assumes that the browser itself has compiled something like pdfjs into the browser code is all or executes code server side and shows you and HTML5 result (i.e. Google). Your question boiled down is "do any browsers support viewing PDF natively" ... the answer is "no". – Kevin Brown Jun 21 '13 at 04:51
  • 1
    Ahh. I get it. I've been thinking about PDFs the same as images but that's not right because, like you both said, PDFs aren't typically handled natively by the browser (the way images are). I think this means a JS solution is actually the safest way to go. @KevinBrown Do you know what the browser support is for pdfjs? It looks like a powerful tool but I'm totally creeped out by the almost non-existent documentation. – emersonthis Jun 21 '13 at 14:28