Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
pdf.js get password-protected file content

I want to retrieve the content of a password-protected file as a File object using PDF.js library. I tried to get the raw data from the promise and convert it to a File. However the file is still encrypted.

Here is a sample of code:

  const loadingTask = pdfjsLib.getDocument(file);

  loadingTask.onPassword = (callback, reason) => {
      callback(password);
  };


  loadingTask.promise.then((pdfDocument) => {
      //Here I tried to retrieve data from `pdfDocument` but it is still encrypted
      
      const data = await pdfDocument.getData(); //The data is still encrypted
      const blob = new Blob([data]);
      const pdfFile = new File([blob], 'name', { type: 'application/pdf' });
  });

Is there a way with PDF.js library to get the decrypted PDF as a File object ?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!