简体   繁体   English

无法在 angular 应用程序中打开受密码保护的 pdf

[英]Unable to open password protected pdf in angular application

i use pdfjs-dist in my angular application to render pdf.我在我的 angular 应用程序中使用pdfjs-dist来渲染 pdf。 but i am unable to open password protected pdf.但我无法打开受密码保护的 pdf。 Is there any other way to verify password for the document and open it.有没有其他方法可以验证文档的密码并打开它。

Use the below code.使用下面的代码。

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) {

});

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

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