【问题标题】:Displaying PDFs in Android Browser在 Android 浏览器中显示 PDF
【发布时间】:2012-04-11 20:35:11
【问题描述】:

浏览到以下地址后,我想显示一个 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 中运行顺利。但是,在 Android 中没有任何反应。 PDF 不显示,也不提示下载。我怎样才能让它与Android一起工作?我需要在脚本中更改什么吗?

【问题讨论】:

    标签: php android pdf download


    【解决方案1】:

    Android 原生浏览器不支持 PDF。您需要将您的网址嵌入到谷歌文档中。试试这个..希望它会有所帮助..

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

    【讨论】:

      猜你喜欢
      • 2014-06-18
      • 1970-01-01
      • 1970-01-01
      • 2014-06-25
      • 2011-06-18
      • 2017-12-28
      • 2017-03-02
      • 1970-01-01
      • 2014-08-03
      相关资源
      最近更新 更多