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.
Related
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.
I have a PDF which is generate via TCPDF on the server side.
When opened in any browser it looks and acts fine, but when opened in Google Chrome - it looks fine but Googles PDF print viewer displays the PDF with about 100px top offset.
And prints it out with that offset...
When I switch the browsers plugins to force using Adobe tools for printing, it looks fine.
What could be the issue?
Tnx!
For future notice, yes there is a documented bug about this in Chrome - BUT it might also help to turn of the "Fit to page" option the print popup window.
I need to open pdf file into browser without Adobe Reader. Is there any API with php which open PDF files into browser.
Regards
No.
PHP runs on the server. The only "browser API" it has access to is HTTP.
If you want to render a PDF on the client, then the client needs a PDF renderer. There are JavaScript PDF readers, but I can't comment on their cross-browser support or maturity.
You can use SWFTools to convert PDFs to Flash. But SWFTools default skins are not looking good at all, so you can check Flexpaper as a viewer.
In case you are going to make your own skin, then could be useful to read: SWFTools (pdf2swf) to properly work with Flex
Another solution is pdf.js (as Quentin point out), but AFAIR this script was not usable(back then, when I looked for) for PDFs with complex structures (complex gradients for example).
If you need to publish documents as "private" you should look at services as Issuu or you will have to protect files from downloading.
If you pdf files are put online and not restricted, you can try using Google Doc Viewer. It's a very nice way to put the Viewer in <iframe /> so that it can be combined with your web page.
https://docs.google.com/viewer
It is not feasible to view the PDF files without a viewer like Adobe Reader. If you just don't want to use Adobe Reader, you may try a PDF viewer plug in for web browser from some other company.
However, if you do not want to use a viewer at all and want to write/build your own viewer then a better option is to convert the PDF to scalable images and then show them on the web page using image tags. You can also create such a viewer using JavaScript.
Even you can find many already available JavaScript based viewers which can show those images.
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
PHP: How to write code in PHP to play video files (not flash) but completely turn off the video download
Yahoo sites do it so far I saw
It's not possible via PHP AFAIK. You have to use JavaScript or HTML5 tag. The problem with HTML5 is, that not every browser supports it yet.