pdf-lib icon indicating copy to clipboard operation
pdf-lib copied to clipboard

Cannot Load Encrypted/Restricted PDF Document

Open conman805 opened this issue 3 years ago • 7 comments

What were you trying to do?

I am unable to load an encrypted document in PDF-lib.

We would ideally like to be able to list out the pages and or make changes to a PDF document even if a permission password is present.

How did you attempt to do it?

samplesecured_256bitaes_pdf.pdf

We triad to call the load function on the attached document.

What actually happened?

We got the below error. However, even when calling load with the specified ignore encryption option, there is a different error that occurs (probably due to lack of support).

Uncaught (in promise) Error: Input document to PDFDocument.load is encrypted. You can use PDFDocument.load(..., { ignoreEncryption: true }) if you wish to load the document anyways. at new EncryptedPDFError (app-5e5bf3a8bd.js:20517:24) at new PDFDocument (app-5e5bf3a8bd.js:16306:19) at Function. (app-5e5bf3a8bd.js:16378:47) at step (app-5e5bf3a8bd.js:6812:23) at Object.next (app-5e5bf3a8bd.js:6793:53) at fulfilled (app-5e5bf3a8bd.js:6783:58)

What did you expect to happen?

The document should load in the library and be able to be manipulated. I am fine if this requires an extra param or setting to enable for encrypted or otherwise protected documents.

Is this functionality on the roadmap or can it be added? What is needed to support the default password and does it apply to my example? https://github.com/Hopding/pdf-lib/issues/134#issuecomment-509452191

How can we reproduce the issue?

    PDFDocument.load(filestream).then(function (pdfDoc) {
    });

Sample PDF - samplesecured_256bitaes_pdf.pdf

Version

1.17.1

What environment are you running pdf-lib in?

Browser

Checklist

  • [X] My report includes a Short, Self Contained, Correct (Compilable) Example.
  • [X] I have attached all PDFs, images, and other files needed to run my SSCCE.

Additional Notes

Similar to issue #291

conman805 avatar Aug 24 '22 20:08 conman805

im facing same problem. I just want to process default encrypted PDFs.

Alokkumar8 avatar Jan 11 '23 14:01 Alokkumar8

im facing same problem. I just want to remove default open password from a pdf

I have the same use case: Decrypting PDFs (with their respective password) to remove the password requirement from the original files.

andreask1 avatar Feb 28 '23 10:02 andreask1

interesting workaround when I was facing a problem being unable to fill a pdf because it had encryption (was readable, but couldn't read or fill form fields) - try printing the PDF to another PDF using chrome, then load that printed one into pdf-lib, the fields will remain but the security settings will be removed.

nathanmal avatar Mar 13 '23 19:03 nathanmal

Why can't we process default encrypted PDFs with this library yet?

Does anyone know of a similar library that has this feature?

brianarpie-forme avatar Sep 07 '23 16:09 brianarpie-forme

You can use PDF.js it supports default encryption.

On Thu, Sep 7, 2023 at 10:09 PM brianarpie-forme @.***> wrote:

Why can't we process default encrypted PDFs with this library yet?

Does anyone know of a similar library that has this feature?

— Reply to this email directly, view it on GitHub https://github.com/Hopding/pdf-lib/issues/1296#issuecomment-1710469589, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEUIPOS422Y2NNIK6YBXFNDXZH2C3ANCNFSM57QUB6DQ . You are receiving this because you commented.Message ID: @.***>

Alokkumar8 avatar Sep 08 '23 12:09 Alokkumar8