PDF не отображается в браузере java swt

Я использую браузер java swt для одностраничного приложения java. В браузере веб-страницы успешно отображают PDF-файлы, но в браузере swt PDF-файлы не отображаются должным образом.
Я использую тег <object/> для отображения 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

                            });
});

person Jeekiran    schedule 03.03.2016    source источник


Ответы (1)


Если вы можете предположить, что установлено средство просмотра системных 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>

src тега embed должен указывать на нужный pdf-файл, для локальных файлов: file://myPath/../test.pdf

person Mohith P    schedule 03.03.2016