JavaScript È°¿ëÆÁ
2017.04.11 / 13:01

PDF Viewer support in mobile browser (iPhone & Android)

jscripter
Ãßõ ¼ö 277

Does <object> tag widely supported in mobile browser?! I'm trying to embed a PDF file but it seems that it is not supported.

I'm using the following html for viewing PDF

<object data="pdf/sample.pdf#view=Fit" type="application/pdf" width="100%" height="400px"> 
    <p>It appears you don't have Adobe Reader or PDF support in this web browser. <a rel="external" href="pdf/sample.pdf">Click here to download the PDF</a></p>
</object>

and using the PDFObject but both of them are not working in mobile browsers!




1down voteaccepted

If embedding isn't important to you you could just link to the PDF on a seperate page.

Safari (and UIWebViews) supports the rendering of PDFs, im not a 100% sure about Android but I suspect its a similar story.

PDF in safari


No browsers can support native rendering of PDF files without a plugin (except Google Chrome as claimed here).

But you can you Google Docs Viewer to display PDF files inside a webpage like explained here.


Load your url inside iframe using google docs

<iframe id="pdfviewer" src="http://docs.google.com/gview?embedded=true&url=YOUR_URL_HERE&amp;embedded=true" frameborder="0" width="100%" height="100%"></iframe>
shareimprove this answer