Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 665
Vishwas R Avatar asked Aug 26 '17 16:08

Vishwas R


People also ask

How can I view PDF files without downloading on my phone?

Turns out that a new feature crept up in Google Drive's 2.3. 544.17 release on January 28. If you have that version or the newer 2.3. 583.13 installed, you'll see that tapping on PDF links in any app (SMS, Chrome, Twitter, WhatsApp, etc...) will immediately open Drive's PDF viewer and start loading them there.

How do I open PDF in Chrome mobile?

Google Drive Viewer allows files to be viewed (without downloading) in Google Chrome for Android. By default, the file will open in a new tab.

Can browsers display PDF?

Right click on your PDF document. Click on 'Open with'. Select Chrome or your browser of choice. You can also open PDFs in any other browser you use regularly.


2 Answers

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.

like image 199
Rishabh Rajgarhia Avatar answered Sep 18 '22 06:09

Rishabh Rajgarhia


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.

like image 26
Muhammad Faisal Alfaruqi Avatar answered Sep 19 '22 06:09

Muhammad Faisal Alfaruqi