HummusJS icon indicating copy to clipboard operation
HummusJS copied to clipboard

Encryption works for Adobe, not in Mac Preview

Open simonaberry opened this issue 6 years ago • 5 comments

I have encrypted a file as follows

  {
     userPassword: '',
     ownerPassword: 'XXX',
     userProtectionFlag: 4,
     version: hummus.ePDFVersion16
   }

If I view the permissions Adobe I see

image

However, if I inspect the exact same file in Mac's Preview application

preview

And Preview is allowing me to happily copy any text ....

Does Mac use a different pdf security specification ??

simonaberry avatar Nov 24 '17 14:11 simonaberry

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)

simonaberry avatar Nov 24 '17 17:11 simonaberry

:-( Tried ePDFVersion15 & ePDFVersion14, but macOs is still not respecting the permissions

simonaberry avatar Nov 24 '17 17:11 simonaberry

How about you try

{
     userPassword: '',
     password: 'XXX',
     ownerPassword: 'XXX',
     userProtectionFlag: 4
}
screen shot 2017-12-03 at 12 15 10 am

This is output of my test pdf from https://github.com/chunyenHuang/hummusRecipe/blob/master/lib/encrypt.js#L14

chunyenHuang avatar Dec 03 '17 08:12 chunyenHuang

unfortunately no - Mac Preview is still not respecting the encryption..... ;-(

simonaberry avatar Dec 03 '17 10:12 simonaberry

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,
    })

mhio avatar Feb 15 '20 20:02 mhio