Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Safari in iOS 8.0 can not display a PDF embedded in a HTML page(with embed tag).

Safari in iOS 8.0 can not display a PDF embedded in a HTML page(with embed tag).

In iOS7.0 or earlier Safari can display the PDF if it is embedded in a HTML page.


demo page:

http://www.broadband-xp.com/test/ios/embed.html


Steps to Reproduce:

1. In iOS 8.0 with Safari access to the following test page:

http://www.broadband-xp.com/test/ios/embed.html


You will not see a PDF there.


2. In iOS 7.0 or earlier with Safari access to the same page.

Then you will see a PDF.


Is this change a bug or an expected behavior?

iPhone 5, iOS 8

Posted on Sep 19, 2014 2:51 PM

Reply
Question marked as Best reply

Posted on Sep 22, 2014 11:10 AM

This issue happens in Safari in iOS 8 because it now uses WKWebView. Applications (web browsers) that still use UIWebView will continue to render the PDF document in an <embed> tag.


Instead of using the <embed> tag to render the first page of the PDF document, a better approach would be to use an <img> tag. Another alternative would be to use an <iframe> to render the PDF, although (in Safari on iOS 8) there is another bug that only renders the first page of a multi-page PDF document inside an <iframe>: After iOS8 upgrade, safari can't display PDF in iframes again

16 replies
Question marked as Best reply

Sep 22, 2014 11:10 AM in response to shimax21

This issue happens in Safari in iOS 8 because it now uses WKWebView. Applications (web browsers) that still use UIWebView will continue to render the PDF document in an <embed> tag.


Instead of using the <embed> tag to render the first page of the PDF document, a better approach would be to use an <img> tag. Another alternative would be to use an <iframe> to render the PDF, although (in Safari on iOS 8) there is another bug that only renders the first page of a multi-page PDF document inside an <iframe>: After iOS8 upgrade, safari can't display PDF in iframes again

Dec 11, 2014 5:37 AM in response to shimax21

Today I upgraded to iOS8.1.2, and was disappointed to see this bug was not fixed yet.

More than two months ago I reported this problem to Apple support, who answered this was the duplicate of the bug which somebody else had reported.

But still this bug has not been fixed at all.

All other PDF-related bugs are not fixed as well.

Jan 28, 2015 7:04 AM in response to shimax21

Today I upgraded to iOS8.1.3, and was disappointed to see this bug was not fixed yet.

More than four months ago I reported this problem to Apple support, who answered this was the duplicate of the bug which somebody else had reported.

But still this bug has not been fixed at all.

All other PDF-related bugs in iOS 8.x are not fixed as well.

Apr 9, 2015 4:14 AM in response to shimax21

Today I upgraded iOS to 8.3, and found an improvement for this issue.

Before there were no contents shown in iOS 8.2 or below in the case of an embedded PDF.

But now the first page of the PDF is shown. So maybe a kind of progress!

Even though originally with an "iframe" tag instead of an "embed" tag the first page of any PDF was successfully displayed even in the iOS8.2 or below.

May 5, 2015 7:30 PM in response to shimax21

Well, it won't help with embedding but you can add this in your header and it will redirect iOS devices directly to the pdf instead of the embedded page.



<script type="text/javascript"> // <![CDATA[

if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {

document.location = "path/to/your.pdf";

} // ]]>

</script>



Or if that won't help make a copy of the page with a link to the pdf instead of embedding it and redirect the iOS devices to the page where they need to click a link.


<script type="text/javascript"> // <![CDATA[

if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) {

document.location = "iOSversion.html";

} // ]]>

</script>


Not nearly as good as Apple just fixing their problem but it will let your PDF be embedded for most while still being functional for Apple people.

Jun 25, 2015 4:59 PM in response to shimax21

It sounds like iOS 8.3 may have fixed the bug, so I apologize for not posting this earlier (although it might still be preferable for some):


If you are okay with it linking to Google Docs, here are instructions for that: http://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html


It provides this code:

<iframe src="http://docs.google.com/gview?url=http://YOUR-URL.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>


You need to replace the emphasized text with your own URL, and you can customize dimensions, etc


(Note, there is no need to actually create a Google document; just use this line of code)


This will show up in Safari, whereas when I simply embed in ios 8.2, it doesn't on my phone

Aug 4, 2015 6:25 PM in response to shimax21

shimax21

Today I upgraded iOS to 8.3, and found an improvement for this issue.

Before there were no contents shown in iOS 8.2 or below in the case of an embedded PDF.

But now the first page of the PDF is shown. So maybe a kind of progress!

Even though originally with an "iframe" tag instead of an "embed" tag the first page of any PDF was successfully displayed even in the iOS8.2 or below.

Thanks for the news. I still use 8.1 and problem still exist, I'm going to upgrade it to iso 8.3.

Dec 1, 2015 12:38 PM in response to shimax21

I was able to get safari to open an embedded pdf with the following


<div id="pdf" class="text_color" style="align:center; width: 100%; height:100%;">

<table border="0" style="width: 100%; border-collapse:collapse; border-spacing: 0px;">

<tr>

<td style="width: 100%; text-align: center; color: red;">

<a style="color: red;" href="NameOfPdf.pdf?xslFile=NameOfXsl.xsl">Click here to open the pdf.</a>

</td>

</tr>

</table>

</div>


This has been verified to work in IOS 9.1. PDF is opened upon clicking on the link. PDF is scrollable with multiple pages. You

also have the option to open the page in IBooks or Adobe Reader with the Open with Option located on the top of page.


Hope this helps.

Aug 24, 2016 2:20 AM in response to shimax21

I still had this problem on iOS 9, with my iPhone SE, when using some websites like when viewing decisions from the Brazilian local labor court.

However, I finally managed to find a workaround using Firefox for iOS: when displaying the same website, Firefox offers a "open in..." (displayed as "abrir no...", as my app is in PT-BR) option that isn't available on Safari.


User uploaded file


By using the new available option, I could save the PDF to my Dropbox, by simply renaming it using the correct .pdf extension.

Safari in iOS 8.0 can not display a PDF embedded in a HTML page(with embed tag).

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.