Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

showing pdf document in safari

I want to show pdf document embedded in html. I am trying code like this but its showing me missing plugin error.

But if I drag the same pdf file to browser it opens it nicely. Why its asking for plugin in html document?

<object data="pdfobject.pdf#view=FitV" type="application/pdf" width="100%" height="100%"></object>
like image 352
coure2011 Avatar asked Nov 24 '11 05:11

coure2011


1 Answers

Safari just updated their browser which will now properly display pdf's in iframes. Back in the summer of 2011 it did not. Make sure you use an id.

 <div id="scroller">
<iframe name="myiframe" id="myiframe" src="viewpdf-safari.php">
</div>

Then in the css add

#myiframe {width:600px; height:100%;} 

Here's the problem you'll run into: As of today, the iframe will display the pdf, yes, but navigation thru the pdf is a pain. With touch scrolling, the whole iframe will try to scroll, and not the pdf, forcing you to use two finger scrolling (one finger to hold down the iframe, the other to slow-scroll).

Other browsers filler the whole width on iframe properly, but safari does not right now. I'd suggest having a button or a link to open the pdf directly in a new window for now, so that users won't have two-finger-hell.

Another alternative is to try to control the scrolling with the outer div, as mentioned in the link below, but I couldn't get it to work.

how to properly display an iFrame in mobile safari

like image 102
Cymbals Avatar answered Oct 05 '22 23:10

Cymbals