"Error: spawn qpdf ENOENT" on Windows with Git Bash
Opened this issue · 4 comments
viniciusknob commented
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn qpdf ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn qpdf',
path: 'qpdf',
spawnargs: [
'--password=017',
'--decrypt',
...
]
AshikNesin commented
@viniciusknob Thanks for reporting the issue. Will look into it.
In the meantime, could you please check if you've installed qpdf in your machine?
viniciusknob commented
@AshikNesin you right! I've forgot to install qpdf, but after installing I saw the following error:
$ node remove-pdf-password PWD remove_pwd_test/n/encrypted.pdf
C:\project\test\node_modules\remove-pdf-password\index.js:10
throw new Error(data.toString());
^
Error: WARNING: remove_pwd_test/n/encrypted.pdf: file is damaged
WARNING: remove_pwd_test/n/encrypted.pdf: can't find startxref
WARNING: remove_pwd_test/n/encrypted.pdf: Attempting to reconstruct cross-reference table
at Socket.<anonymous> (C:\project\test\node_modules\←[4mremove-pdf-password←[24m\index.js:10:9)
←[90m at Socket.emit (events.js:315:20)←[39m
←[90m at addChunk (_stream_readable.js:295:12)←[39m
←[90m at readableAddChunk (_stream_readable.js:271:9)←[39m
←[90m at Socket.Readable.push (_stream_readable.js:212:10)←[39m
←[90m at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)←[39m
My code is:
const removePdfPassword = require('remove-pdf-password');
let pwd = process.argv.filter((item,index) => index == 2);
let files = process.argv.filter((item,index) => index >= 3);
files.forEach(filename => {
const params = {
inputFilePath: filename,
password: pwd,
outputFilePath: filename.replace('.pdf','_unlocked.pdf'),
}
removePdfPassword(params);
});
So, I decided to use native qpdf commands that solved my problem:
qpdf --password=PWD --decrypt --no-warn encrypted.pdf descrypted.pdf
Thanks anyway.
AshikNesin commented
I've tested this only on MacOS. I think it's breaking on Windows. Thanks for letting me know. @viniciusknob
tweetsydotio commented
it is also not working in ubuntu