Php 在Android浏览器中显示PDF

Php 在Android浏览器中显示PDF,php,android,pdf,download,Php,Android,Pdf,Download,浏览到以下地址后,我想显示一个PDF文件: http://www.mydomain.com/myfile 为此,我在.htaccess上使用301重定向,将myfile重定向到myfile.php。然后,该文件包含 <?php $filename = 'files/somefile.pdf'; header('Content-Type: application/pdf'); header('Content-Disposition: inline; filename="somefile.

浏览到以下地址后,我想显示一个PDF文件:

http://www.mydomain.com/myfile
为此,我在.htaccess上使用301重定向,将myfile重定向到myfile.php。然后,该文件包含

<?php
$filename = 'files/somefile.pdf';

header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="somefile.pdf"');
header('Content-Length: ' . filesize($filename));

@readfile($filename);
?>

其主要思想是在浏览器中显示PDF,而不提示用户下载,但在强制下载时,输出文件名变为somefile.PDF。在IE、Firefox、Chrome、Safari和Opera中,一切都进展顺利。然而,在安卓系统中什么都没有发生。PDF不会显示,也不会提示下载。我怎样才能让它与Android一起工作?脚本中有什么需要更改的吗?

Android本机浏览器不支持PDF。你需要将你的url嵌入谷歌文档。试试这个,希望对你有帮助

url="http://docs.google.com/gview?embedded=true&url=http://118.102.182.50/victor/testpdf.aspx?s=9";
webView.loadUrl(url);

Android本机浏览器不支持PDF。你需要将你的url嵌入谷歌文档。试试这个,希望对你有帮助

url="http://docs.google.com/gview?embedded=true&url=http://118.102.182.50/victor/testpdf.aspx?s=9";
webView.loadUrl(url);