Pregunta

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?

¿Fue útil?

Solución

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>

Otros consejos

This is a perfectly acceptable use of an iframe. It has not been deprecated in HTML5, it even has three new tags (sandbox, seamless, and srcdoc). Or you can use <object> as the other answer suggests.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top