bpampuch / pdfmake

Client/server side PDF printing in pure JavaScript
http://pdfmake.org
Other
11.52k stars 2.03k forks source link

Access privileges(copying permission) not working If user/owner password not set #1624

Closed kumarandena closed 5 years ago

kumarandena commented 5 years ago

Hi,

My need is to prevent copying contents from generated pdf.

Issue - I set the permissions object with all settings. Still we can copy the text contents from pdf, If the user/owner password is not set while pdf creation.

Expected - I need to prevent copying contents(Text, Image, ..all) from the pdf but I don't need to set user password at all.

Test Results (Focused only on copying permission):

}


* This PDF file [withUserPwd.pdf](https://github.com/bpampuch/pdfmake/files/2835284/withUserPwd.pdf) was generated with user/owner passwords and worked as expected. 

var dd = { userPassword: '123', ownerPassword: '123456', permissions: { printing: 'highResolution', modifying: false, copying: false, annotating: true, fillingForms: true, contentAccessibility: true, documentAssembly: true }, content: [ 'With user password', 'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines', { image: 'sampleImage.jpg', fit: [100, 100] }, ]

}



Thanks!
liborm85 commented 5 years ago

ownerPassword is required, Set only ownerPassword and not userPassword.

Example:

var dd = {
ownerPassword: '123456',
    permissions: {
    printing: 'highResolution',
    modifying: false,
    copying: false,
    annotating: true,
    fillingForms: true, 
    contentAccessibility: true,
    documentAssembly: true
  },
    content: [
        'With user password',
        'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
        {
            image: 'sampleImage.jpg',
            fit: [100, 100]
        },
    ]

}
kumarandena commented 5 years ago

@liborm85 I didn't noticed that. Setting only ownerPassword did the trick!

Thanks.