-
-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render Encrypted Documents using pdf-lib js library #1601
Comments
I have used this tool to decrypt: https://smallpdf.com/unlock-pdf#r=unlock It has worked well for me so far with pdf-lib. |
We've added support for document decryption and other features on our fork: @cantoo/pdf-lib The project here is not maintained anymore, so you'd probably want to switch. |
thanks! it is very cool, but do you know how to use it in code like javascript ? |
@Jan-Chien This PR is worth following: cantoo-scribe#54 It looks like it uses code from this fork: https://github.com/PhakornKiong/pdf-lib/tree/dev/DocEncrypt perhaps you can try to build from this fork and load your PDF. It looks like if the document is encrypted, it will attempt to decrypt it. (looking at the written tests) |
Why is this project not maintained anymore? |
What were you trying to do?
Hi,
I am trying to render encrypted document using pdf-js library on UI. However, it is throwing the following error:
pdf-lib.js:6475 Uncaught (in promise) Error: Input document to
PDFDocument.load
is encrypted. You can usePDFDocument.load(..., { ignoreEncryption: true })
if you wish to load the document anyways.How did you attempt to do it?
I tried adding { ignoreEncryption: true } property to handle this scenario.
What actually happened?
This is just preventing the exception thrown by the library, but is not rendering the document. Is there any way we can render the encrypted document using pdf-lib js library?
What did you expect to happen?
I am expecting the encrypted pdf to be rendered using pdf-lib js library.
Note: The PDF is rendered perfectly using Postman, I am facing this issue only when rendering the pdf using pdf-lib js library.
How can we reproduce the issue?
We can try to render encrypted pdf using pdf-lib library.
Attached is the PDF file which we are trying to render.
ICF TEMP.pdf
Code:
Javascript:
const pdfDoc: any = await PDFDocument.load(existingPdfBytes, { ignoreEncryption: true });
const pdfDataUri: any = await pdfDoc.saveAsBase64({ dataUri: true });
pdfBase64.value = pdfDataUri;
document.getElementById('view-pdf').src = pdfDataUri + '#toolbar=0&navpanes=0';
HTML
<iframe id="view-pdf" style="width: 100%; height: 95%;"></iframe>Version
1.17.1
What environment are you running pdf-lib in?
Browser
Checklist
Additional Notes
No response
The text was updated successfully, but these errors were encountered: