2017-05-09 307 views
0

有没有一种方法可以让我在不使用Chrome浏览器内置PDF查看器的情况下查看PDF? enter image description here如何在网页上查看PDF,而不使用浏览器内置的PDF查看器?

我想完成的是按文件查看PDF文件。

我设法一页一页地分割一个PDF文件,每一页作为一个单独的文件。 enter image description here

我需要按文件查看PDF,而不是滚动。 当我使用JavaScript查看PDF时,它总是打开chrome的PDF查看器。

编辑:我用pyramid框架作为我的后端。

<script> 
    window.open('test.pdf','mywindow','width=400,height=200') 
</script> 

感谢您的帮助!

+1

你应该使用引导模型来查看你的pdf文件。 –

+0

我想你是指bootstrap模态?我搜查过了,我认为这是不可能的。 –

+0

@GhanshyamBhava,我错了,它实际上可以用模态查看PDF!但有一个小问题,谷歌浏览器说“这个插件不支持”,但是当我在Microsoft Edge上打开它时,它可以正常工作。 –

回答

1

$('.btn').click(function(){ 
 

 
    $('.modal').on('show.bs.modal',function(){  
 
     $(this).find('iframe').attr('src','http://www.tutorialspoint.com/php/php_tutorial.pdf') 
 
    }) 
 
    $('.modal').modal({show:true}) 
 
    
 
    $('iframe').load(function() { 
 
    $('.loading').hide(); 
 
}); 
 
    
 
})
<!-- jQuery library --> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
 

 
<!-- Latest compiled JavaScript --> 
 
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 

 
<button class="btn btn-primary">show modal</button> 
 

 
<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"> 
 
    <div class="modal-dialog modal-lg"> 
 
    <div class="modal-content"> 
 
     <iframe src="" frameborder="0"></iframe> 
 
     </div> 
 
    </div> 
 
</div>

这里的工作片段。

+0

我会用这个。我会应用一些更改以满足我的需求。 –

+0

玩得开心@Oblivion Coder :) –