Search code examples
htmlpdfiframepdf-viewer

iframe alternative to HTML5 for pdf view


I want to display pdf file view in a division on a webpage for reading. I was using iframe for that. But as i searched about it. iframe is deprecated in html5.

Any other compatible(non flash and if possible not html5) way to show pdf content on webpage just like a pdf displayed with an iframe?


Solution

  • The <iframe> is not deprecated at all. At least, the current HTML5 spec draft on <iframe> doesn't say anything about deprecation. In the future please read the specification itself before making ungrounded assumptions.

    There's however an alternative to the <iframe> which allows graceful degradation: the <object> tag which in the below example gracefully degrades to a link when the specified content type is not supported by the browser nor any of its plugins (you know, displaying a PDF file inline requires the Acrobat Reader plugin).

    <object data="/url/to/file.pdf" type="application/pdf" width="500" height="300">
        <a href="/url/to/file.pdf">Download file.pdf</a>
    </object>