[英]Displaying PDFs in Android Browser
我希望在瀏覽到以下地址時顯示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一起使用? 腳本中有什么我需要改變的嗎?
Android原生瀏覽器沒有PDF支持。 您需要使用google doc嵌入您的網址。 嘗試這個..希望它會有所幫助..
url="http://docs.google.com/gview?embedded=true&url=http://118.102.182.50/victor/testpdf.aspx?s=9";
webView.loadUrl(url);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.