Open evolutionxbox opened 3 years ago
Please note that I am using node-qpdf2, but that's just a wrapper around this module.
node-qpdf2
Trying to encrypt a file that has one or more spaces in the name
qpdf .encrypt( '/Users/my/absolute/path/to/A Sample PDF.pdf', { keyLength: 40, password: { user: '', owner: 'YOUR_PASSWORD_TO_ENCRYPT_FOR_OWNER', }, restrictions: { print: 'y', }, }, '/Users/my/absolute/path/to/protected.pdf' ) .then((x) => console.log('Done: ', x)) .catch((e) => console.error('Error: ', e));
Result:
Error: open /Users/my/absolute/path/to/A\ Sample\ PDF.pdf: No such file or directory
I thought that maybe adding double quotes around the path would help, as that is what you do in the shell to allow paths with spaces:
qpdf .encrypt( '"/Users/my/absolute/path/to/A Sample PDF.pdf"', { keyLength: 40, password: { user: '', owner: 'YOUR_PASSWORD_TO_ENCRYPT_FOR_OWNER', }, restrictions: { print: 'y', }, }, '/Users/my/absolute/path/to/protected.pdf' ) .then((x) => console.log('Done: ', x)) .catch((e) => console.error('Error: ', e));
Done: Input file doesn't exist
Using path.resolve also results in the "Input file doesn't exist" error.
path.resolve
Trying to encrypt a file that has one or more spaces in the name
Result:
I thought that maybe adding double quotes around the path would help, as that is what you do in the shell to allow paths with spaces:
Result:
Using
path.resolve
also results in the "Input file doesn't exist" error.