I have a PDF on my website. It works fine when on a computer, but on a phone, there is an extra step for the user. After going to the link with the PDF, they then have to click a link to view it. Is there anyway I can bypass this link? I am assuming not for security reasons, but figured I'd take a shot.

<object data="Resources\myPDF.pdf" type="application/pdf" width="100%" height="100%">
<p><a href="Resources\myPDF.pdf">It looks like you are on a phone. No worries though, just click on this text to
view my PDF in your mobile browser.</a></p>
</object>

If on a computer, myPDF.pdf opens and is shown in the browser when navigated to the page containing the above code. However, when on a browser, the link needs to be clicked in order to view myPDF.pdf. The only thing on the page is myPDF.pdf, so it is OK if nothing else is on the page. Any ideas?

I am looking for a generic solution for all phones, but the only phone I have actually been able to test it on is an iPhone using Safari. Other browsers may give a different result or require a different solution than the scenario I described above.

I do not know phone stuff or even tablets, but it might help to know which phone since they have different OSs and browsers. I suspect that may help others to answer the question.
– closetnocNov 27 '14 at 3:58

1

You can detect whether the user is on a phone or a computer using screensize, screen resolution, user agent and similar methods. For such users, instead of displaying the page, you can do a javascript mediated redirect to the .pdf file directly, bypassing the page display entirely.
– Rana PrathapNov 27 '14 at 16:15

1 Answer
1

You can't force automatic PDF display on all devices because the ability to display embedded content (including pdf's) is dependant on the device having a program/plugin that can interpret the content. even when a desktop browser displays a embedded pdf automatically, it is using a bridge from a program or plug-in (like acrobat reader) to understand how to display the file/content being served to the browser. PDF isn't a native part of HTML language or the languages interpreted by web browsers, especially mobile browsers. Additionally, mobile devices (and desktops for that matter) can still have individual settings regarding security and/or embedded content that prevent the desired behavior. There are a lot of ways to help your desired action along but the direct answer to your question is no.