-
-
Notifications
You must be signed in to change notification settings - Fork 666
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
Dev/doc encrypt #1015
base: master
Are you sure you want to change the base?
Dev/doc encrypt #1015
Conversation
@PhakornKiong thanks for reopening this PR! It's pretty hefty, so it'll be awhile before I can look through all this. Sidenote: If you'd like for folks to be able to use your work without waiting, you might consider making a separate library that people can pass a |
No worries, take your time. It would be difficult to spin off as a separate library as the change rely heavily on the |
This looks awesome; it would be great to see this pulled in and also the ability to decrypt pdfs =] (dealing with that now, trying to decide how to handle it) |
Hi, how can I use it in a browser environment? |
Hello, I'm very interested by this one. Any chance to see this feature added in the near future ? Thanks. |
Hey @Hopding @PhakornKiong, this feature is a great and i see how it could re written outside of pdf-lib so i can keep using the latest release without doing any refactoring in the future, but before i do is it going to be added in the near future? Not a problem at all just curious. |
At this rate, i doubt it will be merge anytime soon. Might be a great solution to those that need this functionality. How would you write it outside of pdf-lib ? (Just curious, since i relied heavily on the parser in pdf-lib) |
This idea is really more a guess. But a while back I found a solution on here to update spot colours in a pdf and has been expanded for other features. So using the research from your blog plus the pdf specification I'm thinking that might work. |
This would be incredibly useful for us. Any idea when it might get merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see anything wrong let get this added :D
Hi~ @PhakornKiong the PR code I use cannot be opened in the adobe reader after encrypting the pdf in my workplace, but it can be opened in other pdf readers (the browser can be opened) |
This feature would be immensely useful. I'm voting to move forward with merging. Any ETA? |
@PhakornKiong What an incredible job! Maybe, while this processes until merge, can you release your fork on npm? |
+1 for adding it in. Anybody from the repo bossmen available for a review? @MatheusHCP I see it was approved, could we merge it in? |
Ok, let me do it this weekend. |
Thanks so much @PhakornKiong! |
decrypt is super helpful as well, any updates on this? thanks! |
@PhakornKiong I fork your repo and build, but error about fs founded, would u kindly tell me how to build correctly? |
Would love to get this implemented. As of right now, there are not a lot of ways to encrypt an already existing pdf using node. |
@PhakornKiong @gonyulian415 are you using the correct version of nodejs? |
Hey @peterpoliwoda, I faced 2 issues while building Phakorn's fork for browser.
Can you guide me how to bundle the fork to make it work on browser? Edit:
npm install --save buffer
// import CryptoJS from 'crypto-js';
import { Buffer } from 'buffer';
import saslprep from './saslprep/index'; @gonyulian415 Please go through this once and let me know whether your issue is resolved or not |
Awesome! Well done sir! |
Hell
Hello, I want to ask this feature will be merge or still is review? |
d067693
to
93dd36e
Compare
Closing this? So is there no hope for this to go in? What's happening? |
@peterpoliwoda I forced pushed and it automatically closed it, probably have to do with history |
Hi @PhakornKiong, with encryption enabled (
|
I'm not 100% sure, would need to check the standard to verify. What tools do you use to display this? Maybe i can take a peek Left is unencrypted, middle is encrypted by ilovepdf, right is from the PR |
Simply viewing the pdf in MS Edge (chromium to be specific).
Both the images of the encrypted pdf are not showing the metadata. Also from Adobe Acrobat Reader Created a sample pdf using
Footnotes |
I'm of the opinion that the default is to encrypt metadata. So probably i would not change this implementation here. https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf |
The encryption is grate, however I’m facing the same issue as PROxZIMA ,metadata are also encrypted, and I can’t reset team by pdfDoc.setTitle(“”) (same as setAuthor, setSubject) |
In most PDF encryption apps and libraries there is an option to enable/disable the encryption of document metadata. I would recommend adding this option so that the developer can choose to encrypt the metadata or leave as-is. |
I try to clean the meta info and save as a temporary pdf then reload the clean meta pdf for encrypted. You know what, the meta info recovered, I just don’t know how it happened, is crazy 😂 |
It works If I remove the meta by adobe reader instead of pdf-lib |
Can you provide steps to reproduce this? If it works then this might be more straightforward to implement. Else the solution would require substantial change in how the PDFwriter keep tracks of all the object, which I haven't really got into |
`const pdfName = "./somePDFWithMeta.pdf"; //step 1 remove meta and save to disk const pdfBytes = await pdfDoc.save(); //step 2 encrypt PDF A simple step for your reference. |
Can anyone know when this can be merged?. Im desperately looking for this PR to get it merged. Thank you. |
If I get a working PR on @cantoo/pdf-lib we can merge it. But it has to be working out of the box. |
stack: 'TypeError: pdfDoc.encrypt is not a function facing this issue while adding encrption to the pdf document. How to resolve tis issue |
Test on @cantoo/pdf-lib |
can confirm encrypt() works on @cantoo/pdf-lib |
Continuation of PR #917 & #243
Hope to get some advanced review on the PR as this is quite a significant addition,
What?
This PR add the feature for user to be able to
Encrypt
an unencrypted file.Why?
Enables the encryption feature in this library
How?
On the branch, you can try it by using the
scratchpad
yarn run scratchpad:start
to start the build, thenyarn scratchpad:run
. It should create a new pdf in the root level. Then you can verify it.Testing?
Manual testing by verifying the permission in PDF Reader application.
Added Integration test
test19.ts
andtest20.ts
innode
File should only be able to open and get decrypted in the PDF Reader if everything is implemented correctly.
Suggestions on testing is welcomed.
New Dependencies?
Crypto.js
Saslprep
Both are famous public libraries.
Screenshots
N/A
Suggested Reading?
Yes
Anything Else?
There are 2 areas that I would need help with on this PR.
How to verify that the
build
is working, as raised in Feature: Document Encryption #917Currently, there is a bug when using
pdfDoc.save({ useObjectStreams: true })
, the file is not able to be opened inAdobe Acrobat Reader
, but works fine on browser and other PDF readers.Checklist
Deno, and thebrowser.