Skip to content
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

Add functions to encrypt PDFs for pdf version 1.3 #2959

Merged
merged 51 commits into from Oct 28, 2020

Conversation

owenl131
Copy link
Contributor

@owenl131 owenl131 commented Oct 14, 2020

#2750 Implement PDF encryption Version 1 Revision 2 for PDF version 1.3. By default the PDF is not encrypted, encryption can be enabled in the options passed when creating the PDF.

The encryption key for streams and string fields depends on a objectId. Thus, the putStream function now takes in an objectId as one of its options. If encryption is not enabled, then the objectId is not required, hence the API is still backward compatible. If encryption is enabled but the objectId is not passed in then an error is thrown.

@owenl131 owenl131 marked this pull request as draft October 14, 2020 16:52
@owenl131 owenl131 marked this pull request as ready for review October 15, 2020 07:56
@HackbrettXXX
Copy link
Collaborator

Thanks! I will review this next week, because I'm very busy this week. But no worries, we will get through with this before the 31st ;)

@owenl131
Copy link
Contributor Author

Sure, no problem. Meanwhile I'll try to figure out why the tests are failing

@owenl131
Copy link
Contributor Author

Hi @HackbrettXXX any chance of checking this out this week?

Copy link
Collaborator

@HackbrettXXX HackbrettXXX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please revert the changes to the files in the dist folder. They are only updated on release.
  • Please add the encryption options also to the types/index.d.ts file and add a test case types/jspdf.test.ts
  • Please also add a unit test with a reference PDF.
  • Just to be sure: did you check that every string outside a content stream is encrypted, as well?

src/jspdf.js Outdated Show resolved Hide resolved
src/libs/md5.js Outdated Show resolved Hide resolved
src/libs/rc4.js Outdated Show resolved Hide resolved
@owenl131
Copy link
Contributor Author

For the strings outside the content stream, so far I have tested with most of the examples. Works for all so far except the acroforms one. I will need to work on that.

@owenl131
Copy link
Contributor Author

owenl131 commented Oct 21, 2020

Perhaps moving forward the outtputing functions might need a refactor? For instance outputting a dict is something common across many modules, so they should all output using a standard interface, which would allow encapsulation for the encryption part.

This was referenced Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants