shimax21

Q: 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

Close

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

  • All replies
  • Helpful answers

Page 1 Next
  • by ddkilzer,Helpful

    ddkilzer ddkilzer Sep 22, 2014 11:10 AM in response to shimax21
    Level 2 (344 points)
    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

  • by M Kaplan,Helpful

    M Kaplan M Kaplan Oct 9, 2014 10:20 AM in response to ddkilzer
    Level 1 (5 points)
    Oct 9, 2014 10:20 AM in response to ddkilzer

    I have the same problem. What can one do? Does one need to wait for the next iOS update? I am on iOS 8.02.

     

    Is it even possible to insert a PDF with an <img> tag? Have never used <iframe> before, but as you say it has its problems too.

  • by ddkilzer,

    ddkilzer ddkilzer Oct 22, 2014 9:28 AM in response to M Kaplan
    Level 2 (344 points)
    Oct 22, 2014 9:28 AM in response to M Kaplan

    These PDF bugs are not fixed as of iOS 8.1.

     

    Yes, you can use a PDF as the source for an <img> tag in Safari.  However, the limitation is that only the first page is rendered, and it may not work across all web browsers.  If you have a single-page PDF document, though, that's a fine solution.

  • by shimax21,

    shimax21 shimax21 Nov 17, 2014 6:35 PM in response to ddkilzer
    Level 1 (10 points)
    Nov 17, 2014 6:35 PM in response to ddkilzer

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

  • by grace4succession,

    grace4succession grace4succession Nov 20, 2014 11:28 AM in response to shimax21
    Level 1 (0 points)
    Nov 20, 2014 11:28 AM in response to shimax21

    Just noticed this problem today.  It's a real bummer that they changed this feature, as it was very useful.  Does anyone know if this bug has been reported?  I am not an Apple Developer, so I cannot report it

  • by shimax21,

    shimax21 shimax21 Dec 11, 2014 5:37 AM in response to shimax21
    Level 1 (10 points)
    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.

  • by shimax21,

    shimax21 shimax21 Jan 28, 2015 7:04 AM in response to shimax21
    Level 1 (10 points)
    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.

  • by DTChristie,Solvedanswer

    DTChristie DTChristie Feb 6, 2015 2:03 PM in response to shimax21
    Level 1 (10 points)
    Feb 6, 2015 2:03 PM in response to shimax21

    When is Apple FINALLY going to make this work again. We are now at at least the fourth major release of iOS 8!!!

     

    It makes one wonder whether they really care. Perhaps the new Chinese buyers of the iPhone 6 Big don't need PDF.

  • by jdhspv,

    jdhspv jdhspv Feb 24, 2015 8:14 AM in response to shimax21
    Level 1 (0 points)
    Feb 24, 2015 8:14 AM in response to shimax21

    Go to Settings - General - Restrictions and make sure Websites is set to Allow all Websites.  That fixed it for me if you use Restrictions in your Settings.

  • by shimax21,

    shimax21 shimax21 Apr 9, 2015 4:14 AM in response to shimax21
    Level 1 (10 points)
    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.

  • by zoinks222,

    zoinks222 zoinks222 May 5, 2015 7:30 PM in response to shimax21
    Level 1 (0 points)
    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.

  • by katherineelise,

    katherineelise katherineelise Jun 25, 2015 4:59 PM in response to shimax21
    Level 1 (0 points)
    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

  • by Long West,

    Long West Long West Aug 4, 2015 6:25 PM in response to shimax21
    Level 1 (0 points)
    Aug 4, 2015 6:25 PM 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.

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

  • by luvJava2,

    luvJava2 luvJava2 Dec 1, 2015 12:38 PM in response to shimax21
    Level 1 (0 points)
    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.

Page 1 Next