HummusJS
HummusJS copied to clipboard
Encryption works for Adobe, not in Mac Preview
I have encrypted a file as follows
{
userPassword: '',
ownerPassword: 'XXX',
userProtectionFlag: 4,
version: hummus.ePDFVersion16
}
If I view the permissions Adobe I see
However, if I inspect the exact same file in Mac's Preview application
And Preview is allowing me to happily copy any text ....
Does Mac use a different pdf security specification ??
From https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/
Note that AES-256 is not supported by the native PDF viewers on OS X/macOS (tested up to OS X 10.10.3) and iOS (tested up to iOS 8.1.3)
:-( Tried ePDFVersion15 & ePDFVersion14, but macOs is still not respecting the permissions
How about you try
{
userPassword: '',
password: 'XXX',
ownerPassword: 'XXX',
userProtectionFlag: 4
}

This is output of my test pdf from https://github.com/chunyenHuang/hummusRecipe/blob/master/lib/encrypt.js#L14
unfortunately no - Mac Preview is still not respecting the encryption..... ;-(
Works for me on 10.14 and [email protected]
It did not work initially for me due to not specifying the blank user password userPassword: ''
like this:
{
version: hummus.ePDFVersion17,
ownerPassword: config.contract_pdf_password,
userProtectionFlag: 4,
}
When I added that in, it was fine:
const pdf_writer = hummus.createWriter(output_file, {
version: hummus.ePDFVersion17,
userPassword: '',
ownerPassword: config.contract_pdf_password,
userProtectionFlag: 4,
})