简体   繁体   English

Javascript-使用PDF.js的总页数pdf?

[英]Javascript - total pages number pdf with PDF.js?

How do I get the total page count with pdf.js? 如何使用pdf.js获取总页数?

<script type="text/javascript">
$( document ).ready(function() {
  var pdf = pdfjs.getDocument('test.pdf');
  alert(pdf.numPages);
});
</script>

I don't know much about pdfjs but you can try this: 我对pdfjs不太了解,但是您可以尝试以下方法:

<script type="text/javascript">
$( document ).ready(function() {
    pdfjs.getDocument('test.pdf').then(function(pdf){
        alert(pdf.numPages);
    });
});
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM