Reactjs reader.result.match(/\/Type[\s]*\/Page[^s]/g)。长度对某些PDF无效

Reactjs reader.result.match(/\/Type[\s]*\/Page[^s]/g)。长度对某些PDF无效,reactjs,Reactjs,它对某些PDF不起作用。它适用于大多数PDF。还有其他的方法写这个吗? 完整代码 我无法共享pdf,因为它与我的工作相关。但这是一份中文文件,一份账单。对于哪种类型的pdf,它不起作用?你能说明它是为哪个pdf工作的吗?我在胡闹,这个工作var window.pages=reader1.result.match(/\/Type[\]*\/Page[^s]/I).length

它对某些PDF不起作用。它适用于大多数PDF。还有其他的方法写这个吗? 完整代码


我无法共享pdf,因为它与我的工作相关。但这是一份中文文件,一份账单。

对于哪种类型的pdf,它不起作用?你能说明它是为哪个pdf工作的吗?我在胡闹,这个工作
var window.pages=reader1.result.match(/\/Type[\]*\/Page[^s]/I).lengthvar window.pages=reader1.result.match(/\/Type[\]*\/Page[^s]/I).lengthlet blob = new Blob([byteArray], { type: 'application/pdf' });
        console.log("Blob :" + blob)
        const fileURL = URL.createObjectURL(blob);
        console.log("File URL :" + fileURL);
        var reader = new FileReader();
        reader.readAsBinaryString(blob);
        reader.onloadend = function(){
        var window.pages = reader.result.match(/\/Type[\s*]*\/Page[^s]/g).length;
          console.log('Number of Pages:', window.pages );
          }