How to support PDF viewing for all mobile browser?

I use

<object> 

to insert a pdf file on my website. eg.

 <object data="abc.pdf" type="application/pdf"> <embed src="abc.pdf" type="application/pdf" /> </object> 

It works on all desktop browsers, but it shows nothing on my Android device. Besides using google pdf viewer (as it significantly reduces pdf quality), is there any way to support all browsers of ios / android devices? Or what is the best way to handle this situation? Since there are many browsers, how can I redirect them to the pdf browser plugin download page, or should I just tell them to get them? (Less convenient). Thanks

+4
source share
4 answers

The best way is to simply add a link to abc.pdf , which opens in a new tab. This is best suited for a mobile browser than for implementing or implementing plugins.

 <a href="abc.pdf" target="_blank">ABC PDF file</a> 
+4
source

One cross-platform solution I found is ViewerJS .

Android-compatible embedding can be done using iFrame, providing both the URL in the ViewerJS project folder and the URL of the attached PDF file (relative to ViewerJS), separated by a hash:

 <iframe src='../ViewerJS/#../../pdfs/pdf.pdf'></iframe> 
0
source

Better use google gview. I had the same problem in my project: PDF opened separately in mobile browsers, while it opened perfectly on the Internet, so I changed it to use Google Doc Gview. An example is given below:

 <iframe src="http://docs.google.com/gview? url=d11xs62myk100c.cloudfront.net/Conference/262/Misc/marcos-ascensin-spanish-national-research-council-csic-spain.ppt&amp;embedded=true'}" frameborder="0" width="100%" height="1000"> </iframe> 
-one
source

you can check the compatibility of your mobile phone and then download and save as .dox

-2
source

Source: https://habr.com/ru/post/1500069/


All Articles