PDF in <iframe> not working on tablets - php

I'm trying to place PDF in <iframe> for my web application. Works fine on all major desktop browsers but doesn't seem to be working on mobile devices. The files are downloaded instead any solution to this?

If you want to display the PDF in a browser manually (as mobile browsers usually don't feature this automatically), you'd have to use some JavaScript framework like pdf.js.
Modern Browsers like Chrome or Firefox have special renderers built-in, whereas mobile browsers don't.

Related

Display pdf generated using mpdf inline in mobile browsers

Is there any way to display pdf generated using mpdf inline in mobile browsers?
I went through mpdf documentation and tried destination option mpdf->output('filename.pdf','I'). It works pretty well across every browser in desktop except IE and doesn't work in mobile-browsers like Firefox, Chrome etc. It starts downloading automatically instead of displaying inline in IE in desktop and all mobile browsers.
Anyways to handle this?
I stumbled upon this StackOverflow post. You can also try Google embeddable PDF Viewer
As per the blog:
Google Docs offers an undocumented feature that lets you embed PDF files and PowerPoint presentations in a web page. The files don't have to be uploaded to Google Docs, but they need to be available online.
based on documentation :
I: send the file inline to the browser. The plug-in is used if available. The name given by $filename is used when one selects the “Save as” option on the link generating the PDF.
You need plug-in installed on your browser to embed the PDF document (Desktop and Mobile). If your browser doesn't has PDF Viewer plug-in, PDF document will be downloaded automatically.
You can use Javascript plugin such as pdfJs to embed your PDF document in cross browsers.

Can I target specific browsers/devices with the Manifest or Appcache file or just exclude the appcache from Desktop browsers?

Essentially I would like to be able to use an appcache file on my site but only for mobile devices, to enable those devices to view the website/webapp I am developing offline, however desktops/laptops often have access to the internet and I would rather these view the site as is, with no manifest/caching etc..
I am aware user agent sniffing is at best unreliable although can provide some good results, if this could be avoided it would be best.
The site/webapp I am developing is built in HTML/CSS/JS/PHP and uses responsive layouts to serve the same pages of the site to each device with customised views/layouts depending on the devices width (using css media queries).
Thanks for any help in advance, all my searches for this specifically have proved unfruitful :(
Update
After Robertc's comments below I would like to clarify that it is Desktop Browsers (ie the very same browsers that are used on laptops) that I would like to exclude any caching from via appcache/manifest file... This is a requirement from client and also from me as programmatically it seems easier to target desktops and laptops together as they are using same software/OS...
More specifically my webapp needs to support caching via appcache/manifest on iOS, Android & Blackberry (although it would be nice to have all tablets/smartphones) so maybe the question is how to find one of these devices and include the appcache reference, however this looks like it is leading down the path of user agent sniffing which I was hoping to avoid...
Because the browser does check the Appcache.manifast before everything else happens, you have to do an additional serverside detection. You cannot load the appcache.manifest by javascript.
Make a Serverside detection on the Useragent and deliver the HTML with manifest if you get a request from iphone, ipad, android etc. and without manifest in the other cases.
User Agent checking is the best approach. You deliver your site for people who doesn't fake there User Agent.
User agent test with php for mobile devices (just add your devices you need):
Mobile regexp user agent
http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/

How to identify the blackberry's browsers

I should identify whether the site is accessed by mobile or web. I am using $_SERVER['HTTP_USER_AGENT'] to identify this. Based on that am loading mobile site.
Everything works fine.
My Problem is, If I change the browser settings in blackberry, from blackberry to Firefox or IE, then it is loading the normal site instead of mobile site.
How to overcome this problem? Please help.
NOTE : Am checking in Blackberry 5
You cannot. You are completely dependent on the browser to tell you what it is. User-agent spoofing blasts that "trust" out of the water.
Instead, you can do "functional" tests in Javascript/CSS that provide features for supporting browsers and fallback mechanisms for non-supporting browsers.
But if you want to switch to a mobile site then you really do just have to do as the browser asks. That's the server's job, anyway; if the user has gone out of their way to pretend that their phone is a normal PC, then that's their choice and your server should just do as it's told.
This is why the option exists in the Blackberry browser in the first place.
As an example, I sometimes find myself making my Android browser spoof itself as Firefox on Windows, so that I can use the normal Facebook site and access features that Facebook haven't implemented on their mobile version.

How to embed PDFs that work in all web and mobile browsers

My client asked me to create a page which contains PDF. I used Embed, Iframe tags, it worked in Mozilla but did not work in IE and Mobile browser.
I know that all browsers will read .pdf directly but I want it to be embed.
Is there any way?
Please help me..
If you give a link to the PDF on the web page, any browser will be able to download the file and then the user can open it in a PDF viewer of his choice.
If you want to embed the PDF document in a web page, then the browser needs to have a PDF plugin installed. This may not be the case with all browsers. The PDF will be displayed only if the PDF viewer application's plugin is registered with the browser.
The other way of embedding the PDF document is to use a server-side component that renders the PDF as ordinary HTML web page elements. Google has an embeddable PDF viewer.
Google Docs offers an
undocumented feature that lets you
embed PDF files and PowerPoint
presentations in a web page. The files
don't have to be uploaded to Google
Docs, but they need to be available
online.
You can also use Mozilla's pdf renderer written in javascript. It is rather complex getting started, but all options are there. It is the pdf reader available in Firefox and extensions exist for other browsers. Fun fact: It is by far the most starred library on github when searching for pdf.
Try using adobe pdf api, i found is very easy and compatible with all browsers.
https://www.adobe.io/apis/documentcloud/dcsdk/pdf-embed.html

Is there a way to force open a new browser window from MOzilla to IE by Onclick function?

Iam getting new window pop up by using window.open(), but need When i click button in Mozilla browser, a new pop window should open in Internet Explorer, Is it possible......
What about non-Microsoft operating systems? Internet Explorer is not available on e.g. Linux. As such this is not possible. Executing arbitrary external applications should not be possible, at least not without the user's explicit permission. That would be a serious security risk.
Why do you want to do this? Does you website not render properly on anything other than IE? If that is so, then you may want to improve the HTML/CSS/Javascript to make it more standards/cross-browser compliant.
Of course, you could just ask or advice the user to view your website in IE. Not a fancy solution, but it has been done that way for ages. Firefox has the IE Tab add-on, which allows users to render pages using IE's render engine inside the Firefox GUI. This makes things slightly more convenient, but it's still a manual process which requires the user's explicit consent.
As a side note, something akin to what you want is possible with the combination IE/Google Chrome Frame. If you add the following meta tag in the target page, then IE with Google Chrome Frame installed will use Google's instead of IE's rendering engine (source):
<meta http-equiv="X-UA-Compatible" content="chrome=1">
I am not aware of any other browser/plugin combination with this feature.
No. Not possible.
If it was possible to run other applications straight from the web, you would already have tons of malware on your computer. Of course this is impossible and not everyone has Windows.
It might be possible if you have control over clients PC (like e.g. company network). There are handlers for special urls in Firefox that allow you to open external application. It requires approval from user. I saw such links for Skype or other IM clients. And one another example is mailto: link.
Well, there are no such compatibilities in DOM, niether there's access necessary for JS to know system capabilities... but I just found this add-on, IE View, that let's you load pages in IE with a right click (using context menu) and mark certain sites to be loaded from IE only.

Categories