Javascript 将PDF内容读取为文本字符串
所以,目前我正在尝试读取一个本地pdf文件,并将其内容转换为字符串。通过这样做,我想在页面上显示字符串。但是,当我尝试读取它时,我得到以下字符串 x��[[o]�8~���吉凯恩��$��我��.��)ڙ}X샢�感应电动机��q0?I�Javascript 将PDF内容读取为文本字符串,javascript,html,string,pdf,stream,Javascript,Html,String,Pdf,Stream,所以,目前我正在尝试读取一个本地pdf文件,并将其内容转换为字符串。通过这样做,我想在页面上显示字符串。但是,当我尝试读取它时,我得到以下字符串 x��[[o]�8~���吉凯恩��$��我��.��)ڙ}X샢�感应电动机��q0?I� const select = document.getElementById("file-selector"); select.addEventListener("change", handleFiles, fal
const select = document.getElementById("file-selector");
select.addEventListener("change", handleFiles, false);
function handleFiles() {
const fileList = this.files; /* now you can work with the file list */
const numFile = fileList.length;
for (let i = 0, numFiles = fileList.length; i < numFiles; i++) {
const file = fileList[i];
console.log("LOP: " + file);
var stream = file.stream();
console.log("CHECK: " + stream);
readar = new FileReader();
readar.readAsText(file);
readar.onload = function() {
console.log(readar.result);
};
readar.onerror = function() {
console.log(readar.error);
};
}