简体   繁体   中英

Unable to open password protected pdf in angular application

i use pdfjs-dist in my angular application to render pdf. but i am unable to open password protected 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) {

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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