2017-05-09 59 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 :) –