jjwilly16 / node-pdftk

A wrapper for PDF Toolkit with streams and promises.
MIT License
141 stars 34 forks source link

pdftk error if permissions passed as concatenated string #26

Closed Reddok closed 5 years ago

Reddok commented 5 years ago

Describe the bug When you set permissions in pdftk if number of permissions are more then one, pdftk return error about unexpected data in output section. For example:

Error: Unexpected data in output section:
      FillIn CopyContents
Exiting.
Errors encountered.  No output created.
Done.  Input errors, so no output created.

It occurs when permission array passed in spawn like concatenated string.

To Reproduce Steps to reproduce the behavior:

const pdftk = require('node-pdftk');

// Works
pdftk
    .input(['Turgor.pdf'])
    .allow(['FillIn'])
    .output('Turgor_secured.pdf')
    .then(() => {
        console.log('done 1 ');
    })
    .catch(err => {
        console.log(1, err);
    });

// Don't works
pdftk
    .input(['Turgor.pdf'])
    .allow(['FillIn', 'CopyContents'])
    .output('Turgor_secured.pdf')
    .then(() => {
        console.log('done 2');
    })
    .catch(err => {
        console.log(2, err);
    });

Expected behavior Create a pdf file with proper permissios without error.

jjwilly16 commented 5 years ago

Sorry for the delay. Hopefully I will get to this sometime this week

jjwilly16 commented 5 years ago

Good catch. This was definitely a bug. I'll publish 2.1.1 to npm today with the fix.