java swt浏览器中不显示PDF
我正在为java单页应用程序使用JavaSWT浏览器。在浏览器中,网页成功显示PDF,但在swt浏览器中,PDF未正确显示。java swt浏览器中不显示PDF,java,pdf,swt,pdf-viewer,Java,Pdf,Swt,Pdf Viewer,我正在为java单页应用程序使用JavaSWT浏览器。在浏览器中,网页成功显示PDF,但在swt浏览器中,PDF未正确显示。 我正在使用标记来显示PDF $(document).on('click', 'input[type=button]', function(){ var datas = '<object data="files/Documents/'+$(this).attr('class')+'#page=1&zoom=130" type=
我正在使用
标记来显示PDF
$(document).on('click', 'input[type=button]', function(){
var datas = '<object data="files/Documents/'+$(this).attr('class')+'#page=1&zoom=130" type="application/pdf" width="100%" height="100%"></object>';
$('#custom-size-dialogBox').dialogBox({
width: screen.width-100,
height: screen.height-100,
hasMask: true,
title: 'View Details',
hasClose: true,
content: datas
});
});
$(文档)。在('click','input[type=button]'上,函数(){
var数据=“”;
$(“#自定义大小对话框”)。对话框({
宽度:screen.width-100,
高度:screen.height-100,
哈斯马斯克:是的,
标题:“查看详细信息”,
哈斯克洛斯:是的,
内容:数据
});
});
如果可以假设安装了系统pdf查看器,则可以通过设置以下HTML来使用浏览器小部件
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
</head>
<body onResize="fit();">
<embed
type="application/pdf"
src="http://www.adobe.com/security/pdfs/riskcompliance_faq.pdf"
id="pdfDocument">
</embed>
<script type="text/javascript">
fit();
function fit() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
document.getElementById('pdfDocument').width = myWidth;
document.getElementById('pdfDocument').height = myHeight;
}</script>
</body>
</html>
fit();
函数拟合(){
var myWidth=0,myHeight=0;
if(typeof(window.innerWidth)=“number”){
//非IE
myWidth=window.innerWidth;
myHeight=window.innerHeight;
}else if(document.documentElement&(document.documentElement.clientWidth | | document.documentElement.clientHeight)){
//IE 6+处于“标准兼容模式”
myWidth=document.documentElement.clientWidth;
myHeight=document.documentElement.clientHeight;
}else if(document.body&(document.body.clientWidth | | document.body.clientHeight)){
//IE4兼容
myWidth=document.body.clientWidth;
myHeight=document.body.clientHeight;
}
document.getElementById('pdfDocument')。宽度=myWidth;
document.getElementById('pdfDocument')。height=myHeight;
}
对于本地文件,嵌入标记的src必须指向所需的pdf:file://myPath/../test.pdf