我在我的角度应用程序中使用pdfjs-dist来呈现 pdf。但我无法打开受密码保护的 pdf。有没有其他方法可以验证文档的密码并打开它。
问问题
602 次
1 回答
0
使用下面的代码。
let pdfJs= require('pdfjs-dist');
pdfJs.getDocument({ url: 'my.pdf', password: 'your password' }).then(function(pdf)
{
let text = [];
for(let i = 1; i <= pdf.numPages; i++) {
pdf.getPage(i).then(function(page) {
page.getTextContent().then(function(data) {
for(let j = 0; j < data.items.length; j++) {
text.push(data.items[j].str);
}
});
});
}
}).catch(function(error) {
});
于 2020-07-24T09:52:15.293 回答