0
pdf文件不從assert文件夾讀取。<Object>標記在android webview中不起作用
標籤沒有在Android的WebView中工作
WebView webview = new WebView(this);
string url = "file:///android_assets/test.pdf";
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl(url);
要加載下面的HTML文件中的WebView。
需要加載pdf,word,excel,ppt。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script src="js/jquery-ui.js" type="text/javascript"></script>
<link href="css/jquery-ui.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function() {
var fileName = "Tulips.txt";
$("#btnShow").click(function() {
$("#dialog").dialog({
modal: true,
title: fileName,
width: 540,
height: 450,
buttons: {
Close: function() {
$(this).dialog('close');
}
},
open: function() {
var object = "<object data=\"{FileName}\" width=\"500px\" height=\"300px\">";
object += "</object>";
object = object.replace(/{FileName}/g, "Files/" + fileName);
$("#dialog").html(object);
}
});
});
});
</script>
<input id="btnShow" type="button" value="Show PDF" />
<div id="dialog" style="display: none">
</div>
</body>
</html>
請讓我知道是否有其他的可能性轉換爲PDF,Word中& EXCEL導入HTML與Android的WebView的幫助。
是否有任何其他可能性在android webview中加載docx,ppt,xls? @CommonsWare – karthick
@karthick:先將它們轉換爲HTML。 – CommonsWare
用代碼更新了我的問題。 – karthick