我正在尝试使用纯JavaScript计算用户上传的pdf文件的页面数

问题描述

文件本身不是blob类型吗?有人可以告诉我我在做什么错吗?

var input = document.getElementById("customFile");
var reader = new FileReader();
reader.readAsBinaryString(input.files[0]);
reader.onloadend = function(){
    var count = reader.result.match(/\/Type[\s]*\/Page[^s]/g).length;
    console.log('Number of Pages:',count );
}
<html>
<body>
 <input type="file" class="custom-file-input" id="customFile" name="filename" accept=".pdf" required>
</body>
</html>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)